• 代码实现模糊搜索,以及排序


    //分页条件展示结果
    function getByPagePro($table,$page,$where=null,$orderBy=null,$pageSize=2){
    global $totalRows;
    $totalRows=getAllRows($table,$where);
    global $totalPage;
    $totalPage=ceil($totalRows/$pageSize);
    if($page<1||$page==null||!is_numeric($page))$page=1;
    if($page>=$totalPage)$page=$totalPage;
    $offset=($page-1)*$pageSize;
    $sql="select p.id,p.pName,p.pSn,p.pNum,p.mPrice,p.iPrice,p.pDesc,p.pubTime,p.isShow,p.isHot,c.name from shop_pro as p join shop_cate c on p.cId=c.id {$where} {$orderBy} limit {$offset},{$pageSize}";
    $rows= fetchAll($sql);
    return $rows;
    }

    //JavaScript实现实现搜索
    function search(){
    if(event.keyCode==13){
    var val=document.getElementById("search").value;
    window.location="listPro.php?keywords="+val;
    }
    }
    function change(val){
    window.location="listPro.php?order="+val;
    }

    @$page=$_REQUEST['page']!=null?$_REQUEST['page']:1;
    @$keywords=$_REQUEST['keywords']?$_REQUEST['keywords']:null;
    @$order=$_REQUEST['order']?$_REQUEST['order']:null;
    $orderBy=$order?"order by $order":null;
    $where=$keywords?"where pName like '%{$keywords}%'":null;
    $pageSize=2;
    $rows=getByPagePro("shop_pro",$page,$where,$orderBy);

  • 相关阅读:
    Topo软件
    如何利用多核CPU来加速你的Linux命令 — awk, sed, bzip2, grep, wc等
    Web学习
    测试Web服务接口
    WebService
    记录几个博客
    Oracle日志性能查看
    设计模式
    hdu 1999 不可摸数
    parfor —— matlab 下的并行循环
  • 原文地址:https://www.cnblogs.com/lsl321/p/7994276.html
Copyright © 2020-2023  润新知