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)){
$data[]=$r;
}
}
And here I declare
if(isset($_GET['find_id'])){
if($obj->findData($_GET['find_id'],"members"))
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>