- 1、本文档共4页,可阅读全部内容。
- 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
一个分页很好的例子
一个很好的分页例子(php+oracle)
?php
$page=isset($_GET[page])?intval($_GET[page]):1;
$display_rows = 5;
$OracleDBConn = OCILogon(hxl,hxl,hxl);
$sql_count = select count(*) from scott.emp;
$row_count=OCIParse($OracleDBConn, $sql_count);
OCIExecute($row_count);
if (OCIFetch($row_count)) {
$num_rows = OCIResult($row_count,1);
}
else {
$num_rows = 0;
}
OCIFreeStatement($row_count);
if (empty($page) || $page == 0) {
$page = 1;
}
// The start range from where the results should be printed
$start_range = (($ 1) * $display_rows) + 1;
// The end range to where the results should be printed
$end_range = $page * $display_rows;
$sql = SELECT empno, ename, ROW_NO FROM (SELECT ;
$sql .= empno, ename, ROWNUM ROW_NO FROM (SELECT ;
$sql .= empno,ename FROM scott.emp ORDER BY empno)) WHERE ROW_NO BETWEEN ;
$sql .= $start_range. AND .$end_range;
// start results formatting
echo table width=95% border=1 cellspacing=1 cellpadding=2 align=center;
echo tr bgcolor=#666666;
echo tdbfont color=#FFFFFFempno/font/b/td;
echo tdbfont color=#FFFFFFename/font/b/td;
echo tdbfont color=#FFFFFFrow_no/font/b/td;
echo /tr;
if ($num_rows != 0) {
// Parse the SQL string execute it
$rs=OCIParse($OracleDBConn, $sql);
OCIExecute($rs);
// get number of columns for use later
$num_columns = OCINumCols($rs);
while (OCIFetch($rs)){
echo tr;
for ($i = 1; $i ($num_columns + 1); $i++) {
$column_value = OCIResult($rs,$i);
echo TD$column_value/TD;
}
echo /tr;
}
} else {
// Print a message stating that no records was found
echo trtd align=centerSorry! No records was found/td/tr;
}
// Close the table
echo /TABLE;
// free resources and close connection
OCIFreeStatement($rs);
OCILogoff($OracleDBConn);
?
div align=center
?php
// Here we will print the links to the other pages
// Calculating the amount of pages
if ($num_rows % $display_rows == 0) {
$total_pages = $num_rows / $display_rows;
} else {
$total_pages = ($num_rows / $display_rows) + 1;
settype($total_pages, integer); // Rounding the
文档评论(0)