mysql - Creating a simple database PHP search engine -
i try create simple search engine on php, connect database , search string table attribute. , based on keyword, search results display table rows have same keyword string. i'm using php version 5.6.21
search.php
<html> <body> <form action="" method="get"><center> search: <input type="text" name="search" placeholder="enter keywords" /><br><br> <input type="submit" name="submit" value="submit" /> <center> </form> <hr> <?php $hostid= 'localhost'; $user='root'; $pass=''; $db= 'projectdata'; mysqli_connect($hostid, $user, $pass); mysql_select_db($db); if(isset($_get['submit'])){ $search_value=$_get['search']; $query="select * book title '%$search_value%'"; $run=mysql_query($query); if($run===false){ die(mysql_error()); } while ($row=mysql_fetch_array($run)) { $book_id=$row['book_id']; $title=$row['title']; $date_purchased=$row['date_purchased']; $loan_status=$row['loan_status']; echo "<table><tr><th>book id</th><th>title</th><th>date purchased</th><th>loan status</th>"; echo "<tr><td>$book_id</td><td>$title</td><td>$date_purchased</td><td>$loan_status</td></tr>"; } } ?> </body> </html>
how ever, didn't return , there no errors. below projectdata.php
<?php $hostid= 'localhost'; $user='root'; $pass=''; $db= 'projectdata'; $link = mysqli_connect($hostid, $user, $pass, $db); if (!$link) { die('connect error (' .mysqli_connect_errno(). ') ' .mysqli_connect_error()); } echo 'success... ' .mysqli_get_host_info($link). "\n"; $query8 = "create table book(book_id int, title varchar(100), date_purchased timestamp, loan_status varchar(10))"; $query9 = "insert book values(1023, 'the prisoner of zenda', '2008-7-04', 'available'), (2311, 'rupert of hentzau','2001-7-10', 'available'), (7854, 'management of information system', '2010-6-14', 'available'), (4507, 'introduction c++', '2012-1-19', 'available'), (5319, 'computer networking 13th edition', '2013-5-29', 'available'), (3076, 'introduction web programming', '2008-4-26', 'available'), (6901, 'foundation of quantum mechanics', '2008-7-04', 'available')"; if (mysqli_query($link,$query8) ===true) { echo ("table book created.<br>"); } if (mysqli_query($link,$query9) ===true) { echo ("values have been inserted book.<br><br>"); } mysqli_close($link); ?>