PHP develops a simple book background management system to implement book query function
We have already implemented the new book management paging function of the book backend management system.
The paging function queried here is basically the same as mentioned above.
This section mainly explains the query function and adds the query function to the paging function.
Use the SQL LIKE operator to search for a specified pattern in a column in the WHERE clause.
Query book information by selecting the type and entering the query fields.
<?php $SQL = "SELECT * FROM yx_books where ".$_POST['seltype']." like ('%".$_POST['coun']."%')"; ?>
Also add the selection type and query input field to the data displayed on each page
<?php $SQL = "SELECT * FROM yx_books where ".$_POST['seltype']." like ('%".$_POST['coun']."%') order by id desc limit $startno,$pagesize"; ?>
Finally, loop out the database query data through the while statement
<?php while($rows=mysqli_fetch_assoc($rs)) { ?> <tr align="center"> <td class="td_bg" width="7%"><?php echo $rows["id"]?></td> <td class="td_bg" width="28%" height="26"><?php echo $rows["name"]?></td> <td class="td_bg" width="12%" height="26"><?php echo $rows["price"]?></td> <td class="td_bg" width="24%" height="26"><?php echo $rows["uploadtime"]?></td> <td class="td_bg" width="12%" height="26"><?php echo $rows["type"]?></td> <td class="td_bg" width="24%"> <a href="update.php?id=<?php echo $rows['id'] ?>" class="trlink">修改</a> <a href="del.php?id=<?php echo $rows['id'] ?>" class="trlink">删除</a></td> </tr> <?php } ?>
The functions of displaying the home page, previous page, next page, and last page at the bottom are basically similar to the previous new book management paging function.
<tr> <th height="25" colspan="6" align="center" class="bg_tr"> <?php if($pageno==1) { ?> 首页 | 上一页 | <a href="?pageno=<?php echo $pageno+1?>">下一页</a> | <a href="?pageno=<?php echo $_POST['seltype']?>">末页</a> <?php } else if($pageno==$pagecount) { ?> <a href="?pageno=1">首页</a> | <a href="?pageno=<?php echo $pageno-1?>">上一页</a> | 下一页 | 末页 <?php } else { ?> <a href="?pageno=1">首页</a> | <a href="?pageno=<?php echo $pageno-1?>">上一页</a> | <a href="?pageno=<?php echo $pageno+1?>" class="forumRowHighlight">下一页</a> | <a href="?pageno=<?php echo $pagecount?>">末页</a> <?php } ?> 页次:<?php echo $pageno ?>/<?php echo $pagecount ?>页 共有<?php echo $recordcount?>条信息 </th> </tr>