Elena Misheva Elena Misheva - 10 months ago 40
PHP Question

connect function with button in php

I have function to select all the data in my database with SELECT, and also made a form where I create a button for searching data in database by name, last name and id number, but I cant connect the button with my function to show me the data that I am searching for.

I think that I must create a event on button to show me the searched data.

I will show you my code for function:

public function findData ($id,$table){

$sql = "SELECT `name`, `lastname`, `id_number` FROM `members`
WHERE `name` LIKE '%".$word."%'
OR `lastname` LIKE '%".$word."%'
OR `id_number` LIKE '%".$word."%';";
$q = $this->conn->query($sql) or die("failed!");
while($r = $q->fetch(PDO::FETCH_ASSOC)){

And here I declare


Please help me what to do to connect the function the button

This is my form

<form action="user.php" method="get">
<h4>Име</h4> <textarea cols="10" rows="1" name="find_id"></textarea>
<h4>Презиме <h4> <textarea cols="10" rows="1" name="find_id"></textarea>
<h4>Матичен број <h4> <textarea cols="10" rows="1" name="find_id"></textarea>
<input type="submit" value="Submit" name="find_id"></form>


Please try this

     //call your function here 

Your HTML file

  <form action="connect.php" method="get">
 <input type="submit" value="Submit"      name="find_id"></form>

Or use jQuery using ajax .