php - Missing the result printed from database -


my purpose search book type input keyboard , count it. have error: counting number of book right when print, miss result. example, put 'f' show 7 result( right) print 2 two result. here code:

<form action="" method="post">         enter type of book here:<input type="text" size="20" name="sbt"> <br />         <input type="submit" name="sb" value="search">     </form>     <table align="center" border="1" width="600">         <thead><tr align="center">     <tr align="center">             <td><b>book id</b></td>             <td><b>book title</b></td>             <td><b>book author</b></td>             <td><b>pulished year</b></td>             <td><b>book type</b></td>             <td><b>status</b></td>         </tr>         <?php         if (isset($_post['sb'])) {             $s="";             if ($_post['sbt'] == null) {                   echo "please re-enter <br>";                 } else                 {                   $s = $_post['sbt'];                 }             $q = "select * book book_type '%$s%' ";             $r= mysqli_query($conn,$q);             while($row = mysqli_fetch_array($r)) {              ?>         <tr align="center">                 <td><?php echo $row['book_no'];?></td>                 <td><?php echo $row['book_title'];?></td>                 <td><?php echo $row['book_author'];?></td>                 <td><?php echo $row['book_year'];?></td>                 <td><?php echo $row['book_type'];?></td>                 <td>                 <?php                  if ($row['book_quantity'] == 1) {                                 echo "available";                             }                 else {                                 echo "not available";                              }                    ?>                  </td>              <?php              $c=" select count(distinct(book_no)) totaltype book book_type '%$s%'";              $s= mysqli_query($conn, $c);              if (mysqli_num_rows($s)> 0 )              {                 $row2= mysqli_fetch_array($s);                 echo " total book type result:"."{$row2['totaltype']}";             }         }           ?>          <?php } ?>     </table> 

remove "%" before $s , try.

for example:

$query = mysql_query("select * table the_number '$yourphpvar%'"); 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

node.js - Using Node without global install -

php - CakePHP HttpSockets send array of paramms -