zoukankan      html  css  js  c++  java
  • 搜索框制作

    利用在查询语句中加入模糊查询的条件以达到关键字模糊搜索的目的:like+通配符(%  _)

    <form>关键字:<input type="text" name="keyword" value="" /><input type="submit" value="搜索" /></form>
    
    <?php
    //需要将sql查询语句改为:$sql="select * from table_name where username like '%$keyword%' order by id".$limit;
    $keyword=$_GET['keyword'];
    if (empty($keyword)){
        $where='';
        $kword='';
    }else{
        $where=" where username like '%".$keyword."%'";
        $kword='&keyword='.$keyword;
    }
    
    //需更改分页制作以及显示数据内容的查询语句
    $sql01="select count(*) from table_name".$where;
    $sql="select * from table_name".$where." order by id desc".$limit;
    ?>
    
    <!--修改分页的超链接-->
    <a href="?page=1<?php echo $kword;?>">首页</a>
    <a href="?page=<?php echo ($page_num-1).$kword;?>">上一页</a>
    <a href="?page=<?php echo ($page_num+1).$kword;?>">下一页</a>
    <a href="?page=<?php echo ($page_count).$kword;?>">尾页</a>
  • 相关阅读:
    菜单范式
    PIC18F26K20
    单片机中串口通信模型
    STM8S103之GPIO
    STM8S103之ADC
    二叉树最近公共祖先
    全排列
    整数翻转
    完全二叉树节点个数
    二叉树的深度
  • 原文地址:https://www.cnblogs.com/zhouwanqiu/p/9182583.html
Copyright © 2011-2022 走看看