trying to search database using php pdo script please help if you can

Please help really need this code to be searching the database for every possibilities, so if the last name is entered then the first name, address etc should also appear. Thanks here is my code

<?php include "mysqlconnect.php"; $ok=true; try { $dbh = new PDO('mysql:host='.$hostname.';dbname='.$database, $username, $password); } catch (PDOException $e) { $ok = false; echo("Database connection failed, please try again later.

If fault persists, Call me "); } $var1 = str_replace(array('%','_'),'',$_POST['var1']); if (!$var1) { exit('Invalid form value: '.$var1); } $query = "SELECT * FROM 'employees' WHERE 'LastName' LIKE :search OR 'fuller' LIKE :search"; $stmt = $dbh->prepare($query); $stmt->bindValue(':search', '%' . $var1 . '%', PDO::PARAM_INT); $stmt->execute(); /* Fetch all of the remaining rows in the result set */ print("Fetch all of the remaining rows in the result set:\n"); $result = $stmt->fetchAll(); foreach( $result as $row ) { echo $row["id"]; echo $row["title"]; } ?>

Which part isn’t working for you?

Sponsor our Newsletter | Privacy Policy | Terms of Service