php and mysql database not working when i do search -


i having problem php code. have created database

    id int(11) not null auto_increment,     isbn varchar2  not null,     title varchar2 not null,     author varchar2 not null,     publisher varchar2 not null,     year date not null,     primary key (`id`) 

i have list of books in mysql database:

isbn: 0763754891 title: web development javascript , ajax illumination author: richard allen, kai qian , lixin tao, xiang fu publisher: jones& bartlett date: 2009  isbn: 9780763754204 title: software architecture , design illuminated author: kai qian, xiang fu, lixin tao, jorge diaz-herrera,chong-wei xu publisher: jones & bartlett date: 2009  isbn: 0763734233 title: java web development illuminated author: kai qian, richard allen, mia gan,bob brown publisher: jones & bartlett date: 2007  isbn: 0471644463 title: component oriented programming author: andy wang, kai qian publisher: wiley date: 2005  isbn: 9781441906052 title: embedded software development c author: kai qian, david den haring, li cao publisher: springer date: 2010 

here html , php code

<html> <head> <title>book store</title> </head> <body> <h3> book store </h3>  <p> *****welcome use book store system***** <p> <form action = "" method = "get"> find entries are:<br/> author: <input type = "text" name = "author" /> title : <input type = "text" name = "title"  /> <p></p> year  :      <p></p>     <select name = "select">     <option value=""/></option>     <option value=2005/>2005</option>     <option value=2007/>2007</option>     <option value=2009/>2009</option>     <option value=2010/>2010</option>     </select>     <p></p>         <input type = "submit" name="submit" value="search"/> </form> </body> </html>    <?php session_start();  if($_get){      $author = $_get['author'];     $title = $_get['title'];     $select = $_get['select'];      $connect = mysql_connect("localhost", "root", "") or die(mysql_error());      if($connect)     {         mysql_select_db("mysql", $connect);          $query = "select * bookstore author='" . $author . "' or      title='" . $title . "' ";          $query2 = "select * bookstore year = '" . $select ."' ";          $result = mysql_query($query) or die(mysql_error());         $result2 = mysql_query($query2) or die(mysql_error());          while($row = mysql_fetch_array($result)){              echo $row['isbn'] . "<br/>" . $row['title'] . "<br/>" .  $row['author'] . "<br/>" . $row['publisher'] . "<br/>" . $row['year'] . "<br/>";          }         while($row2 = mysql_fetch_array($result2)){             echo $row2['isbn'] . "<br/>" . $row2['title'] . "<br/>" .  $row2['author'] . "<br/>" . $row2['publisher'] . "<br/>" . $row2['year'] . " <br/>";         }     } else {         die(mysql_error());      } mysql_free_result($result); mysql_close(); }  ?> 

i should able perform search "qian" author , "java" title works when write entire book title or authors' names in search area. how fix this?

= exact match. need use like search pattern.

$query = "select *            bookstore            author '%" . $author . "%'            or title '%" . $title . "%' "; 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -