<br />
<b>Warning</b>:  Undefined array key "HTTP_ACCEPT_LANGUAGE" in <b>/www/wwwroot/01xj.net/wp-content/plugins/wp-ue/main.php</b> on line <b>13</b><br />
{"id":166,"date":"2011-10-08T11:27:47","date_gmt":"2011-10-08T11:27:47","guid":{"rendered":"http:\/\/www.01xj.net\/0\/?p=166"},"modified":"2011-10-08T11:27:47","modified_gmt":"2011-10-08T11:27:47","slug":"adodbsmarty%e7%9a%84%e4%b8%80%e4%b8%aaphp%e5%88%86%e9%a1%b5%e7%b1%bb%e5%b8%a6%e6%90%9c%e7%b4%a2%e5%88%86%e9%a1%b5","status":"publish","type":"post","link":"https:\/\/www.01xj.net\/?p=166","title":{"rendered":"ADODB+SMARTY\u7684\u4e00\u4e2aPHP\u5206\u9875\u7c7b(\u5e26\u641c\u7d22\u5206\u9875)"},"content":{"rendered":"[code]\n<?php\nclass Page{\/\/\u5206\u9875\u7c7b\nvar $table;\/\/\u8868\u540d\nvar $n;\/\/\u6bcf\u9875\u663e\u793a\u6761\u6570\nvar $d;\/\/\u5f53\u524d\u9875\nvar $num;\/\/\u603b\u6761\u6570\nvar $j;\/\/\u4e00\u5171\u51e0\u9875\nvar $start;\/\/\u8d77\u59cb\u4f4d\u7f6e\nvar $url;\/\/\u5f53\u524d\u6587\u4ef6\nvar $py;\/\/\u504f\u79fb\u51e0\u4e2a\u5355\u4f4d,\u4ee5\u5f53\u524d\u9875\u4e3a\u4e2d\u5fc3\u5bf9\u79f0\u504f\u79fb\nvar $yc;\/\/\u6ea2\u51fa\u591a\u5c11\u4e2a\u5355\u4f4d\uff0c\u4ee53,5,7.....\n  \nfunction Getallnum($sql){\/\/\u5f97\u5230\u603b\u6761\u6570\n  global $conn;\n  $this->table=$table;<br \/>\n  $all=$conn->GetAll($sql);<br \/>\n  $this->num=count($all);<br \/>\n  return $this->num;<br \/>\n}<br \/>\nfunction Getallpage($n){\/\/\u5f97\u5230\u4e00\u5171\u51e0\u9875<br \/>\n  $this->n=$n;<br \/>\n  $this->j=ceil($this->num\/$this->n);<br \/>\n  return $this->j;<br \/>\n}<br \/>\nfunction Getpage($d,$url){\/\/\u5206\u9875<br \/>\n  $d=$_GET[&#8216;page&#8217;];<br \/>\n  $this->d=$d;<br \/>\n  $this->url=$url;<br \/>\n  if (empty($this->d) || $this->d <0 || $this->d==0 || $this->d==1){<br \/>\n   $this->d=1;<br \/>\n   if(($this->j)>1){<br \/>\n    $str=&#8221;\u9996\u9875&#8221;;<br \/>\n    $str.=$this->mathurl(2,5);<br \/>\n    $str.=&#8221;<a href='\".$this->url.&#8221;page=&#8221;.($this->d+1).&#8221;&#8216;>\u4e0b\u4e00\u9875<\/a>&#8220;;<br \/>\n   }<br \/>\n  }elseif(($this->d)>=$this->j){<br \/>\n   $this->d=$this->j;<br \/>\n   $str=&#8221;<a href='\".$this->url.&#8221;page=&#8221;.($this->d-1).&#8221;&#8216;>\u4e0a\u4e00\u9875<\/a>&#8220;;<br \/>\n   $str.=$this->mathurl(2,5);<br \/>\n   $str.=&#8221;\u5c3e\u9875&#8221;;<br \/>\n  }else{<br \/>\n   $str=&#8221;<a href='\".$this->url.&#8221;page=&#8221;.($this->d-1).&#8221;&#8216;>\u4e0a\u4e00\u9875<\/a>&#8220;;<br \/>\n   $str.=$this->mathurl(2,5);<br \/>\n   $str.=&#8221;<a href='\".$this->url.&#8221;page=&#8221;.($this->d+1).&#8221;&#8216;>\u4e0b\u4e00\u9875<\/a>&#8220;;<br \/>\n  }<br \/>\n  return $str;<br \/>\n  return $this->d;<br \/>\n  return $this->url;<br \/>\n}<br \/>\nfunction Getstart(){\/\/\u8d77\u59cb\u4f4d\u7f6e<br \/>\n  if(empty($this->d)){<br \/>\n   $this->start=0;<br \/>\n  }else{<br \/>\n   $this->start=$this->n*($this->d-1);<br \/>\n  }<br \/>\n  return $this->start;<br \/>\n}<br \/>\nfunction Getend($e){\/\/\u6bcf\u9875\u663e\u793a\u6761\u6570<br \/>\n  return $this->d=$e;<br \/>\n}<br \/>\nfunction options(){\/\/\u8df3\u8f6c\u83dc\u5355<br \/>\n  $opt=&#8221; <input type='text' size='2' style='height: 16px; border:1px solid #ccc;' onkeydown=\\\"javascript: if(event.keyCode==13) location='\".$this->url.&#8221;page=&#8217;+this.value;\\&#8221;>&#8221;;<br \/>\n  return $opt;<br \/>\n}<br \/>\nfunction mathurl($py,$yc){\/\/\u6570\u5b57\u5bfc\u822a<br \/>\n  $this->py=$py;<br \/>\n  $this->yc=$yc;<br \/>\n  $co=$_GET[&#8216;page&#8217;];\/\/\u5f53\u524d\u9875\u7801<br \/>\n  $do=$this->j;\/\/\u603b\u9875\u6570<br \/>\n  if($this->j<=$this->yc){\/\/\u603b\u9875\u6570\u5c0f\u4e8e\u6216\u7b49\u4e8e$yc\u65f6<br \/>\n   for ($o=1;$o<=$this->j;$o++){<br \/>\n    $murl.=&#8221; <a href='\".$this->url.&#8221;page=&#8221;.$o.&#8221;&#8216;>&#8221;.$o.&#8221;<\/a> &#8220;;<br \/>\n   }<br \/>\n  }elseif($co>($do-$this->py)){\/\/\u9875\u7801\u8d85\u8fc7\u603b\u9875\u6570\u65f6<br \/>\n   $co=$do;<br \/>\n   for ($v=($co-($this->yc-1));$v<=$do;$v++){\/\/\u5f80\u5de6\u504f\u79fb$yc\u4e2a\u5355\u4f4d\n    $murl.=\" <a href='\".$this->url.&#8221;page=&#8221;.$v.&#8221;&#8216;>&#8221;.$v.&#8221;<\/a> &#8220;;<br \/>\n   }<br \/>\n  }elseif($co<=$this->py){<br \/>\n   $co=1;<br \/>\n   for ($v=$co;$v<($co+$this->yc);$v++){\/\/\u5f80\u53f3\u504f\u79fb$yc\u4e2a\u5355\u4f4d<br \/>\n    $murl.=&#8221; <a href='\".$this->url.&#8221;page=&#8221;.$v.&#8221;&#8216;>&#8221;.$v.&#8221;<\/a> &#8220;;<br \/>\n   }<br \/>\n  }else{<br \/>\n   for($k=($co-$this->py);$k<$co;$k++){\/\/\u5f80\u5de6\u504f\u79fb$py\u4e2a\u5355\u4f4d\n   $murl.=\" <a href='\".$this->url.&#8221;page=&#8221;.$k.&#8221;&#8216;>&#8221;.$k.&#8221;<\/a> &#8220;;<br \/>\n   }<br \/>\n   for ($v=$co;$v<=($co+$this->py);$v++){\/\/\u5f80\u53f3\u504f\u79fb$py\u4e2a\u5355\u4f4d<br \/>\n    $murl.=&#8221; <a href='\".$this->url.&#8221;page=&#8221;.$v.&#8221;&#8216;>&#8221;.$v.&#8221;<\/a> &#8220;;<br \/>\n   }<br \/>\n  }<br \/>\n  return $murl;<br \/>\n}<br \/>\n}\/*<br \/>\nrequire_once(&#8220;..\/class\/Smarty.class.php&#8221;);<br \/>\ninclude &#8220;..\/adodb\/adodb.inc.php&#8221;;<br \/>\ninclude &#8220;..\/connect.php&#8221;;<br \/>\n$page=new Page();<br \/>\n$sql=&#8221;select * from class&#8221;;<br \/>\n$p[&#8216;num&#8217;]=$page->Getallnum($sql);<br \/>\n$p[&#8216;page&#8217;]=$page->Getallpage(10);<br \/>\n$p[&#8216;link&#8217;]=$page->Getpage(1,&#8221;class.inc.php?&#8221;);<br \/>\n$p[&#8216;start&#8217;]=$page->Getstart(0);<br \/>\n$p[&#8216;end&#8217;]=$page->Getend(10);<br \/>\n$p[&#8216;opt&#8217;]=$page->options();<br \/>\n$a=$conn->GetAll(&#8220;select * from class limit &#8220;.$p[&#8216;start&#8217;].&#8221;,&#8221;.$p[&#8216;end&#8217;].&#8221;&#8221;);<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;\u4e0a\u9762\u7684\u662f\u6570\u636e\u5e93\u5206\u9875\u7684\u4f8b\u5b50&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;\u4e0b\u9762\u7684\u662f\u641c\u7d22\u5206\u9875\u7684\u4f8b\u5b50&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\n$s=$_GET[&#8216;s&#8217;];<br \/>\n$si=$_POST[&#8216;s&#8217;];<br \/>\nif(empty($_GET[&#8216;key&#8217;])){<br \/>\n$key=$si;<br \/>\n}else{<br \/>\n$key=$_GET[&#8216;key&#8217;];<br \/>\n}<br \/>\nif($s==&#8221;s&#8221;){<br \/>\n$page=new Page();<br \/>\n$sqa=&#8221;select cname from class where cname like binary  &#8216;%&#8221;.$key.&#8221;%'&#8221;;<br \/>\n$p[&#8216;num&#8217;]=$page->Getallnum($sqa);<br \/>\n$p[&#8216;page&#8217;]=$page->Getallpage(6);<br \/>\n$p[&#8216;link&#8217;]=$page->Getpage(1,&#8221;class.inc.php?s=s&#038;key=&#8221;.$key.&#8221;&#038;&#8221;);<br \/>\n$p[&#8216;start&#8217;]=$page->Getstart(0);<br \/>\n$p[&#8216;end&#8217;]=$page->Getend(6);<br \/>\n$sql=&#8221;select cname from class where cname like binary  &#8216;%&#8221;.$key.&#8221;%&#8217; limit &#8220;.$p[&#8216;start&#8217;].&#8221;,&#8221;.$p[&#8216;end&#8217;].&#8221;&#8221;;<br \/>\n$rs=$conn->GetAll($sql);<br \/>\n}<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-\u4e0b\u9762\u7684\u662fsmarty\u5e94\u7528&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br \/>\n$smarty = new Smarty;<br \/>\n$smarty->assign(&#8220;page&#8221;,$p);<br \/>\n$smarty->assign(&#8220;show&#8221;,$a);<br \/>\n\/\/$smarty->assign(&#8220;se&#8221;,$rs);<br \/>\n$smarty->display(&#8216;class.inc.htm&#8217;);<br \/>\n*\/<br \/>\n?><\/p>\n[\/code]\n","protected":false},"excerpt":{"rendered":"<p>[code]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-166","post","type-post","status-publish","format-standard","hentry","category-phpjsshell"],"_links":{"self":[{"href":"https:\/\/www.01xj.net\/index.php?rest_route=\/wp\/v2\/posts\/166","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.01xj.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.01xj.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.01xj.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.01xj.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=166"}],"version-history":[{"count":1,"href":"https:\/\/www.01xj.net\/index.php?rest_route=\/wp\/v2\/posts\/166\/revisions"}],"predecessor-version":[{"id":167,"href":"https:\/\/www.01xj.net\/index.php?rest_route=\/wp\/v2\/posts\/166\/revisions\/167"}],"wp:attachment":[{"href":"https:\/\/www.01xj.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=166"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.01xj.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=166"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.01xj.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=166"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}