首页 > 代码库 > yourphp基本语句

yourphp基本语句

实例化页面代码

1.时间代码:{$vo.createtime|toDate=###,‘Y-m-d H:i:s‘}

2.连接:{:U(‘Pro/arr‘)}  如:<form action="{:U(‘Pro/arr‘)}" name="form" method="post">

php页面中的连接

URL(Service-Pro/arr)如:$url = URL(Service-Pro/arr).&p=;   // 5.定义连接

 

查询语句$where[status]=1;

$where[name]=百度;$list = $m->where($where)->select();还有其他几中1.$where = and status =1;2.$where[status]=1;3.$list = $m->where(status=1)->select(); 4.$where[title] = array(like,%.$title.%);

 

自己写分页代码

public function arr(){        $m = M(problem);          //0.基本条件        $pagesize = 1;        $p = $_GET[p];                 if(empty($_GET[title])){            $title = ‘‘;            }else{            $title = $_GET[title];                    }        $where[title] = array(like,%.$title.%);   // 1.查询条件        $where[status] = 1;                $totalNum=$m->where($where)->count();   // 2.总几条数据        $totalpage = intval($totalNum/$pagesize);   // 3.计算分页[共几页]        $totalp = $totalNum%$pagesize;        if($totalp !=0){            $totalpage +=1;            }                $nowpage = $p;                          // 4. 翻页分4个节点【当前页,上一页,下一页,尾页】        if($p<=1){            $nowpage = 1;        }        $nowsize = $nowpage*$pagesize-$pagesize;    // [当前条数]                        $firstpage = 1;        $prevpage = $nowpage-1;  //[上一页]        if($prevpage<=$nowpage){            $prevpage = $nowpage;            }        $nextpage = $nowpage+1;   //[下一页]        if($nextpage>=$totalpage){            $nextpage = $totalpage;            }        $lastpage = $totalpage;  //[尾页]                $url = URL(Service-Pro/arr).&title=.$title.&p=;   // 5.定义连接        $page = <a class="a1">共.$totalNum.条 当前.$nowpage./.$totalpage.页</a>;        $page .= <a href="http://www.mamicode.com/.$url.$firstpage.">第一页</a>;        $page .= <a href="http://www.mamicode.com/.$url.$prevpage.">上一页</a>;        $page .= <a href="http://www.mamicode.com/.$url.$nextpage.">下一页</a>;        $page .= <a href="http://www.mamicode.com/.$url.$lastpage.">尾页</a>;                $list = $m->where($where)->limit($nowsize,$pagesize)->order(createtime desc)->select();        $this->assign(ser_title,$title);        $this->assign(page,$page);        $this->assign(list,$list);        $this->display();    }