PDO::ERRMODE_EXCEPTION )); }catch (Exception $e){ die("Error : ".$e->getMessage()); } if (isset($_POST['search'])) { if (isset($_POST['query'])) { $q = $_POST['query']; // Search in `authors` table $req = $db->prepare('SELECT id FROM `authors` WHERE firstname=:q OR lastname=:q OR username=:q OR website=:q'); $req->execute(array( "q"=>$q )); $result_author = $req->fetchAll(); if (empty($result_author)) { $req = $db->prepare('SELECT * FROM `records` WHERE (recordist_name LIKE "%:q%" OR file_name LIKE "%:q%" OR species LIKE "%:q%" OR subspecies LIKE "%:q%" OR sound_type LIKE "%:q%" OR date=:q OR remarks LIKE "%:q%")'); $req->execute(array( "q"=>$q )); $result = $req->fetchAll(); // print_r($result); } else { foreach ($result_author as $row) { $author_id = $row['id']; $req = $db->prepare('SELECT * FROM `records` WHERE author_id=:author_id'); $req->execute(array( "author_id"=>$author_id )); $result = $req->fetchAll(); } } // print_r($result); } } else { // header('Location: /'); } if (empty($result)) { // header('Location: /'); } else { ?>
File name | Author | License | Date |
---|---|---|---|
=$row['file_name']?> | =$row['recordist_name']?> | =$row['license']?> | =$row['date']?> =$row['time']?> |