• 标准搜索案例


    html

    <div class="alert sb-alert alert-gray margin-left-50">
        <div class="row">
        <div class="col-lg-2">
            <span class="input-group input-group-sm">
                <span class="input-group-addon"><b>姓名:</b></span>
                <input type="text" class="form-control" id="name" value="{$name}" aria-describedby="base">
            </span>
        </div>
    
        <div class="col-lg-2">
            <span class="input-group input-group-sm">
                <span class="input-group-addon"><b>手机号:</b></span>
                <input type="text" class="form-control" id="telphone" value="{$telphone}" aria-describedby="base">
            </span>
        </div>
    
        <div class="col-lg-2">
            <span class="input-group input-group-sm">
                <span class="input-group-addon"><b>状态:</b></span>
                <select id="status" class="form-control" style="position: relative; left:-4px;z-index: 1;" aria-describedby="object">
                    <option value="0">请选择</option>
                    <option value="-1" <?php if($status == -1) echo 'selected'; ?>>未处理</option>
                    <option value="1" <?php if($status == 1) echo 'selected'; ?>>已发货</option>
                    <option value="2" <?php if($status == 2) echo 'selected'; ?>>已丢弃</option>
                </select>
            </span>
        </div>
    
    
            <button type="button" class="btn btn-sm btn-primary" style="float: right; margin-right: 15px;" id="search">
                <i class="fa fa-search" aria-hidden="true"></i> 搜索
            </button>
        </div>
    
    </div>
    

    js

    $("#search").on('click', function () {
        var pathname = window.location.pathname;
    
        var name = $("#name").val();
        var telphone = $("#telphone").val();
        var status = $("#status").val();
    
        var tail = '?search=1';
    
        if(name){
            tail += '&name='+name;
        }
        if(status){
            tail += '&status='+status;
        }
    
        if(telphone){
            tail += '&telphone='+telphone;
        }
        window.location.href = "http://" + window.location.host + pathname + tail;
    });
    
    

    php

    // search
    $where = [];
    if ($name = $_GET['name']) {
        $where['name'] = ['like',$name.'%'];
        $this->assign('name',$name);
    }
    
    if ($telphone = $_GET['telphone']) {
        $where['telphone'] = ['like',$telphone.'%'];
        $this->assign('telphone',$telphone);
    }
    
    if ($status = $_GET['status']) {
        if ($status == -1) {
            $where['status'] = 0;
        } else {
            $where['status'] = $status;
        }
        $this->assign('status',$status);
    }
    
    $data_list=$women_get->where($where)->order('id desc')->limit($start.','.$step)->select();
    

    干净利落

  • 相关阅读:
    linux下 C++ 读取mat文件 MATLAB extern cyphon scipy 未完待续
    mshadow笔记
    mem_fun 例子
    gedit embeded terminal 设置字体 颜色
    decltype typename
    gcc4.9.1新特性
    C++开发者都应该使用的10个C++11特性 转
    如何加快C++代码的编译速度 转 ccache
    cout关闭输出缓冲,调试用
    boost range zhuan
  • 原文地址:https://www.cnblogs.com/jiqing9006/p/10451941.html
Copyright © 2020-2023  润新知