在线等,高手请多指教,php odbc oracle分页问题????
$query="select rownum
from addcost
where reader_id='".$_SESSION["readerid"]."'
and to_char(time,'yyyy-mm-dd')>='".$strDateStart."'
and to_char(time,'yyyy-mm-dd')<='".$strDateEnd."'";
$result=odbc_do($conn,$query);
$NumRecords=odbc_record_count($result,$currentrow); //计算总行数
odbc_free_result($result);
$recordperpage=2; //每页显示多少条记录
$pages=ceil($NumRecords/$recordperpage); //总页数
if (empty($offset))
{
$offset=1;
}
$currentpage=ceil($offset/$recordperpage); //显示当前页
$endset=$offset+$recordperpage;
$query1="select rownum,cost_id,reader_id,cost,time,qcost,hcost,user_id
from addcost
where reader_id='".$_SESSION["readerid"]."'
and to_char(time,'yyyy-mm-dd')>='".$strDateStart."'
and to_char(time,'yyyy-mm-dd')<='".$strDateEnd."'
and rownum between '".$offset."' and '".$endset."'";
echo $query1;
$result1=odbc_do($conn,$query1);
$row1=odbc_fetch_row($result1);
if (!($row1==false))
{
?>
<table border=1 width=78% align="right" cellpadding="4" cellspacing="1" style="font-size:15px;" >
<?php
while(!($row1==false))
{
echo "<tr>";
echo "<td>".odbc_result($result1,2)."</td>"; //充值记录号
echo "</tr>";
$row1=odbc_fetch_row($result1);
}
echo "共有".$NumRecords."条记录".$pages."页当前页:".$currentpage."";
for ($i=1; $i <= $pages; $i++)
{
$newoffset=($recordperpage*($i-1))+1;
echo "<a href='".$PHP_SELF."?offset=".$newoffset."'>".$i."</a>";
}
$nextoffset=$recordperpage*$currentpage+1;
$prevoffset=$recordperpage*($currentpage-2)+1;
//判断是否需要上一页连接
if (($offset>1)&&($offset<=$pages))
{
echo "<a href='".$PHP_SELF."?offset=$prevoffset'>上一页</a>";
}
//判断是否需要下一页连接
if (($pages!=0) && ($offset<$pages))
{
echo "<a href='".$PHP_SELF."?offset=$nextoffset&opt=tpage&tdatestart=$strDateStart&tdateend=$strDateEnd&tstradd=$strAdd'>下一页</a>";
}
问题点数:10、回复次数:0Top




