php - Search in database and echo result -
php - Search in database and echo result -
i'm having problem search, error phone call fellow member function query() on non-object in /data/web/virtuals/81877/virtual/www/subdom/hdb/page_search.php on line 8
** if(!empty($_get["search"]) , isset($_get["search"])) { $search = $_get["search"]; $query= "select * tblskupina concat_ws(' ',nazev,zanr) '%$search%'"; $user = $pdo->query($query); while($user_final = $user->fetch()) { echo " <div class='text_search'> <a href='profil?profile=".$user_final["id_osoba"]."'>" .$user_final["jmeno"]." ".$user_final["prijmeni"]. "</a> "; } } ?>**
make sure have pdo connection before query:
$pdo = new pdo('mysql:host=localhost;dbname=test', $user, $pass); or if in external file have include file , have utilize global $pdo access object like:
// hold connection include `db_config.php` global $pdo; php mysql database search
Comments
Post a Comment