if (!$conn) { echo "<h1>error - could not connect to oracle</h1>"; exit; }
/* 如果连接成功,$conn就是一个连接符。否则,脚本将结束并且输出“could not connect to oracle”的错误信息 现在开始来分析并且创建你的sql语句,由无限制的查询结果得到可以记数的记录。 在这里的格式语句“select count(*) from table_name”相当于count(),是个sql函数将会在数据库里执行。比由依靠php计算得到的返回结果要好。 */
$sql = "select count(*) from table_name";
$stmt = ociparse($conn, $sql); if(!$stmt) { echo "<h1>error - could not parse sql statement.</h1>"; exit; }
// now loop through the pages to create numbered links // ex. 1 2 3 4 5 next >> for ($i=1;$i<=$pages;$i++) { // check if on current page if (($offset/$limit) == ($i-1)) { // $i is equal to current page, so don display a link echo "$i "; } else { // $i is not the current page, so display a link to page $i $newoffset=$limit*($i-1); echo "<a href="$php_self?offset=$newoffset">$i</a> n"; } }
//检查当前页面是否为最后一页 if (!((($offset/$limit)+1)==$pages) && $pages!=1) { // not on the last page yet, so display a next link $newoffset=$offset+$limit; echo "<a href="$php_self?offset=$newoffset">next >></a><p>n"; }