PHP+Oracle分页问题请教!!!

babycl 2007-11-12 05:43:27
//初始化页面模版
$oTmpl = new PhpTemplate("./template/colligatenews.php");

//获取当前页数
if(! isset($_GET["page"]))
{
$PageNum = 0;
}
else if(! is_numeric($_GET["page"]))
{
die("<p align='center'><font color='red'>错误!</font></p>");
}
else
{
$PageNum = $_GET["page"];
}

//初始化数据库连接
$o = new Oracle($gDbUser, $gDbPass, $gDbIsp);
if(!$o->HasConnected())
{
die($o->GetLastErrorMsg());
}

//查询综合新闻记录
$zhcount = 10;//综合新闻显示条数
$sql = "select dc_title,dn_id,TO_CHAR(DD_DATE,'YYYY-MM-DD HH24:MI:SS') DT , from site_news order by dd_date desc";
$Sql .= "limit ".($PageNum * 10).", 10";
$Rs = $o->Query($sql, 0, $zhcount);
if($Rs === false)
{
echo($o->GetLastErrorMsg());
}

$zhNum = $o->GetAffectedRows();//综合新闻的条数
if ($zhNum == 0)
{
$oTmpl->InsertParag("{%colligatenews%}", " ");
$oTmpl->InsertParag("{%news_id%}", "-1");
$oTmpl->InsertParag("{%zhtime%}", " ");
}
else
{
$oTmpl->RepeatParag("<!--{%RepeatzhxwStart%}-->", "<!--{%RepeatzhxwEnd%}-->", $zhNum - 1);//循环显示
$i = 0;
foreach($Rs as $Row)//循环取记录
{
$TmpStr = "";
if(ChsStrLen($Row["DC_TITLE"]) > 30)
{
$TmpStr = SubChs($Row["DC_TITLE"], 0, 29)."...";
}
else
{
$TmpStr = $Row["DC_TITLE"];
}
$oTmpl->InsertParag("{%colligatenews%}", iconv($gDbCharset, "UTF-8", $TmpStr));
$oTmpl->InsertParag("{%news_id%}", $Row["DN_ID"]);
$oTmpl->InsertParag("{%zhtime%}", substr($Row["DT"], 0, 10));
$i ++;
}
if($i < 10)
{
$oTmpl->InsertAllParag("{%zhtime%}", " ");
$oTmpl->InsertAllParag("{%colligatenews%}", " ");
}
}


// 查询信息数量情况
$Sql = "select count(*) as TOTAL_PAGES from site_news order by dn_id desc";
$CountRs = $o->Query($Sql);
if($CountRs === false)
{
$o->Destroy();
die("Faild When Query !");
}


// 处理分页情况
$TotalMembers = $CountRs[0]["TOTAL_PAGES"];
$TotalPages = ceil($TotalMembers / 10.0);
if($TotalMembers == 0)
{
$oTmpl->InsertParag("{%Current-Page%}", "0");
}
else
{
$oTmpl->InsertParag("{%Current-Page%}", $PageNum + 1);
}
$oTmpl->InsertParag("{%Total-Page%}", $TotalPages);
$oTmpl->InsertParag("{%Total-Members%}", $TotalMembers);

if($TotalPages != 0)
{
$oTmpl->RepeatParag("<!--{%OptRepeatStart%}-->", "<!--{%OptRepeatEnd%}-->", $TotalPages - 1);
for($i = 0; $i < $TotalPages; $i ++)
{
$oTmpl->InsertParag("{%PageValue%}", $i);
$oTmpl->InsertParag("{%PageNum%}", $i + 1);
if($i == $PageNum)
{
$oTmpl->InsertParag("{%isSelectd%}", "selected");
}
else
{
$oTmpl->InsertParag("{%isSelectd%}", "");
}
}
}
else
{
$oTmpl->DeleteParag("<!--{%OptRepeatStart%}-->", "<!--{%OptRepeatEnd%}-->");
}


if($PageNum > 0)
{
$PrevPage = $PageNum - 1;
}
else
{
$PrevPage = 0;
}
if($PageNum < $TotalPages - 1)
{
$NextPage = $PageNum + 1;
}
else
{
$NextPage = $TotalPages - 1;
}

$oTmpl->InsertParag("{%PrevPage%}", $PrevPage);
$oTmpl->InsertParag("{%NextPage%}", $NextPage);


echo($oTmpl->GetContent());
$o->Destroy();
$oTmpl->Destroy();


以上程序实现分页显示功能,一页10条记录。现在页面报ORA-00936: 和语法错误
小妹现由网站设计向PHP程序员转向,编程中遇到一些问题,恳请各位哥哥姐姐指教。在此有礼啦!!
...全文
62 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
oop2000 2007-11-13
  • 打赏
  • 举报
回复
oracle 为何不用package?
fdclf 2007-11-12
  • 打赏
  • 举报
回复
up

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧