<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>http://www.jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>http://www.jackxiang.com/post//</link>
<title><![CDATA[[smarty分页]ADODB+SMARTY的一个PHP分页类]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[WEB2.0]]></category>
<pubDate>Thu, 05 Apr 2007 10:41:05 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	<?php<br/>class Page&#123;//分页类<br/>var $table;//表名<br/>var $n;//每页显示条数<br/>var $d;//当前页<br/>var $num;//总条数<br/>var $j;//一共几页<br/>var $start;//起始位置<br/>var $url;//当前文件<br/>var $py;//偏移几个单位,以当前页为中心对称偏移<br/>var $yc;//溢出多少个单位，以3,5,7.....<br/> &nbsp;<br/>function Getallnum($sql)&#123;//得到总条数<br/> &nbsp;global $conn;<br/> &nbsp;$this->table=$table;<br/> &nbsp;$all=$conn->GetAll($sql);<br/> &nbsp;$this->num=count($all);<br/> &nbsp;return $this->num;<br/>&#125;<br/>function Getallpage($n)&#123;//得到一共几页<br/> &nbsp;$this->n=$n;<br/> &nbsp;$this->j=ceil($this->num/$this->n);<br/> &nbsp;return $this->j;<br/>&#125;<br/>function Getpage($d,$url)&#123;//分页<br/> &nbsp;$d=$_GET['page'];<br/> &nbsp;$this->d=$d;<br/> &nbsp;$this->url=$url;<br/> &nbsp;if (empty($this->d) &#124;&#124; $this->d <0 &#124;&#124; $this->d==0 &#124;&#124; $this->d==1)&#123;<br/> &nbsp; $this->d=1;<br/> &nbsp; if(($this->j)>1)&#123;<br/> &nbsp; &nbsp;$str="首页";<br/> &nbsp; &nbsp;$str.=$this->mathurl(2,5);<br/> &nbsp; &nbsp;$str.="<a href='".$this->url."page=".($this->d+1)."'>下一页</a>";<br/> &nbsp; &#125;<br/> &nbsp;&#125;elseif(($this->d)>=$this->j)&#123;<br/> &nbsp; $this->d=$this->j;<br/> &nbsp; $str="<a href='".$this->url."page=".($this->d-1)."'>上一页</a>";<br/> &nbsp; $str.=$this->mathurl(2,5);<br/> &nbsp; $str.="尾页";<br/> &nbsp;&#125;else&#123;<br/> &nbsp; $str="<a href='".$this->url."page=".($this->d-1)."'>上一页</a>";<br/> &nbsp; $str.=$this->mathurl(2,5);<br/> &nbsp; $str.="<a href='".$this->url."page=".($this->d+1)."'>下一页</a>";<br/> &nbsp;&#125;<br/> &nbsp;return $str;<br/> &nbsp;return $this->d;<br/> &nbsp;return $this->url;<br/>&#125;<br/>function Getstart()&#123;//起始位置<br/> &nbsp;if(empty($this->d))&#123;<br/> &nbsp; $this->start=0;<br/> &nbsp;&#125;else&#123;<br/> &nbsp; $this->start=$this->n*($this->d-1);<br/> &nbsp;&#125;<br/> &nbsp;return $this->start;<br/>&#125;<br/>function Getend($e)&#123;//每页显示条数<br/> &nbsp;return $this->d=$e;<br/>&#125;<br/>function options()&#123;//跳转菜单<br/> &nbsp;$opt=" <input type='text' size='2' style='height: 16px; border:1px solid #ccc;' onkeydown=&#92;"javascript: if(event.keyCode==13) location='".$this->url."page='+this.value;&#92;">";<br/> &nbsp;return $opt;<br/>&#125;<br/>function mathurl($py,$yc)&#123;//数字导航<br/> &nbsp;$this->py=$py;<br/> &nbsp;$this->yc=$yc;<br/> &nbsp;$co=$_GET['page'];//当前页码<br/> &nbsp;$do=$this->j;//总页数<br/> &nbsp;if($this->j<=$this->yc)&#123;//总页数小于或等于$yc时<br/> &nbsp; for ($o=1;$o<=$this->j;$o++)&#123;<br/> &nbsp; &nbsp;$murl.=" <a href='".$this->url."page=".$o."'>".$o."</a> ";<br/> &nbsp; &#125; &nbsp;<br/> &nbsp;&#125;elseif($co>($do-$this->py))&#123;//页码超过总页数时<br/> &nbsp; $co=$do;<br/> &nbsp; for ($v=($co-($this->yc-1));$v<=$do;$v++)&#123;//往左偏移$yc个单位<br/> &nbsp; &nbsp;$murl.=" <a href='".$this->url."page=".$v."'>".$v."</a> ";<br/> &nbsp; &#125;<br/> &nbsp;&#125;elseif($co<=$this->py)&#123;<br/> &nbsp; $co=1;<br/> &nbsp; for ($v=$co;$v<($co+$this->yc);$v++)&#123;//往右偏移$yc个单位<br/> &nbsp; &nbsp;$murl.=" <a href='".$this->url."page=".$v."'>".$v."</a> ";<br/> &nbsp; &#125;<br/> &nbsp;&#125;else&#123;<br/> &nbsp; for($k=($co-$this->py);$k<$co;$k++)&#123;//往左偏移$py个单位<br/> &nbsp; $murl.=" <a href='".$this->url."page=".$k."'>".$k."</a> ";<br/> &nbsp; &#125; &nbsp; <br/> &nbsp; for ($v=$co;$v<=($co+$this->py);$v++)&#123;//往右偏移$py个单位<br/> &nbsp; &nbsp;$murl.=" <a href='".$this->url."page=".$v."'>".$v."</a> ";<br/> &nbsp; &#125; <br/> &nbsp;&#125;<br/> &nbsp;return $murl; &nbsp;<br/>&#125;<br/>&#125;/*<br/>require_once("../class/Smarty.class.php");<br/>include "../adodb/adodb.inc.php";<br/>include "../connect.php";<br/>$page=new Page();<br/>$sql="select * from class";<br/>$p['num']=$page->Getallnum($sql);<br/>$p['page']=$page->Getallpage(10);<br/>$p['link']=$page->Getpage(1,"class.inc.php?");<br/>$p['start']=$page->Getstart(0);<br/>$p['end']=$page->Getend(10);<br/>$p['opt']=$page->options();<br/>$a=$conn->GetAll("select * from class limit ".$p['start'].",".$p['end']."");<br/>--------------------------上面的是数据库分页的例子-------------------------------<br/>--------------------------下面的是搜索分页的例子--------------------------------------<br/>$s=$_GET['s'];<br/>$si=$_POST['s'];<br/>if(empty($_GET['key']))&#123;<br/>$key=$si;<br/>&#125;else&#123;<br/>$key=$_GET['key'];<br/>&#125;<br/>if($s=="s")&#123;<br/>$page=new Page();<br/>$sqa="select cname from class where cname like binary &nbsp;'%".$key."%'";<br/>$p['num']=$page->Getallnum($sqa);<br/>$p['page']=$page->Getallpage(6);<br/>$p['link']=$page->Getpage(1,"class.inc.php?s=s&key=".$key."&");<br/>$p['start']=$page->Getstart(0);<br/>$p['end']=$page->Getend(6);<br/>$sql="select cname from class where cname like binary &nbsp;'%".$key."%' limit ".$p['start'].",".$p['end'].""; &nbsp; <br/>$rs=$conn->GetAll($sql);<br/>&#125;<br/>-------------------------下面的是smarty应用-------------------------------------------------<br/>$smarty = new Smarty;<br/>$smarty->assign("page",$p);<br/>$smarty->assign("show",$a);<br/>//$smarty->assign("se",$rs);<br/>$smarty->display('class.inc.htm');<br/>*/<br/>?><br/>
]]>
</description>
</item><item>
<link>http://www.jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] [smarty分页]ADODB+SMARTY的一个PHP分页类]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>