ThinkPHP3.2.3查询两个日期之间的数据

HTML页面:

起始时间:    结束时间: 

JavaScript部分:
用到日期插件,这里就不做描述了,有时间再补上

function rqcxSub(){
    var rqstart = $("#rqstart").val();
    if (rqstart == '') {
        layer.alert("请输入起始日期", {icon: 2}, function (index) {
            $("#rqstart").focus();
            layer.close(index);
        });
        layer.closeAll('loading');
        return;
    }
    var rqend = $("#rqend").val();
    if (rqend == '') {
        layer.alert("请输入结束日期", {icon: 2}, function (index) {
            $("#rqend").focus();
            layer.close(index);
        });
        layer.closeAll('loading');
        return;
    }
    //校验成功,提交
    $('#fpcx').submit();
}

}


ThinkPHP部分:

public function 方法名()
{
    $rqstart = I('rqstart');
    $rqend = I('rqend');
    $date = date('Y-m-d');
    $this->assign('rqstart', $date);
    $this->assign('rqend', $date);
    $begintime = str_replace('-', '', $rqstart) . '000000';
    $endtime = str_replace('-', '', $rqend) . '235959';
    $map['lrrq'] = array(array('EGT', $begintime), array('ELT', $endtime));
    //分页
    // 实例化模型
    $xxbmx = M('表名');
    $count = $xxbmx->where($map)->count();// 查询满足要求的总记录数
    $Page = new \Think\Page($count, C('DB_PAGENUM'));// 实例化分页类
    $show = $Page->show();// 分页显示输出
    $result = $xxbmx->where($map)->limit($Page->firstRow . ',' . $Page->listRows)->select();

    $this->assign('result', $result);
    $this->assign('page', $show);
    $this->assign('rqstart', $rqstart);
    $this->assign('rqend', $rqend);
    $this->display();
}

 

你可能感兴趣的:(my,blog)