一个ORACLE分页程序_PHP教程

php中文网
发布: 2016-07-13 17:26:53
原创
1226人浏览过

Paging Test oracle8i"); putenv("TNS_ADMIN=$ORACLE_HOME/network/admin"); $OracleDBConn = OCILogon("purk","purk","lengana.world"); // This query counts the records $sql_count = "SELECT COUNT(*) FROM SAMPLE_TABLE"; // Parse the SQL string & execute it $row_count=OCIParse($OracleDBConn, $sql_count); OCIExecute($row_count); // From the parsed & executed query, we get the amount of records found. // Im not storing this result into a session variable because it allows for // new records to be shown as it is entered by another user while the result // is printed. if (OCIFetch($row_count)) { $num_rows = OCIResult($row_count,1); } else { $num_rows = 0; // If no record was found } // Free the resources that were used for this query OCIFreeStatement($row_count); // We need to prepare the query that will print the results as a page. I will // explain the query to you in detail. // If no page was specified in the url (ex. http://mysite.com/result.php?page=2), // set it to page 1. if (empty($page) || $page == 0) { $page = 1; } // The start range from where the results should be printed $start_range = (($page - 1) * $display_rows) + 1; // The end range to where the results should be printed $end_range = $page * $display_rows; // The main query. It consists of 3 "SELECT" statements nested into each // other. The center query is the query you would normally use to return the // records you want. Do you ordering and "WHERE" clauses in this statement. // We select the rows to limit our results but because the row numbers are // assigned to the rows before any ordering is done, lets the code print the // result unsorted. // The second nested "SELECTED" assigns the new row numbers to the result // for us to select from. $sql = "SELECT PK_ID, FIELD1, FIELD2, FIELD3, ROW_NO FROM (SELECT PK_ID, "; $sql .= "FIELD1, FIELD2, FIELD3, ROWNUM ROW_NO FROM (SELECT PK_ID, FIELD1, "; $sql .= "FIELD2, FIELD3 FROM SAMPLE_TABLE ORDER BY FIELD3)) WHERE ROW_NO BETWEEN "; $sql .= $start_range." AND ".$end_range; // start results formatting echo ""; echo ""; echo "PK ID"; echo "Field 1"; echo "Field 2"; echo "Field 3"; echo "Row No"; echo ""; 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 ""; for ($i = 1; $i
Total pages: ".$total_pages."
"; echo "
Number of records: ".$num_rows."
"; echo "
The SQL Query is: ".$sql."
"; ?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/531928.htmlTechArticlePaging Test PK ID ; echo Field 1 ; echo Field 2 ; echo Field 3 ; echo Row No ; echo ; if ($num_rows != 0) { // Parse the SQL string OCIExecute($rs); // get number of columns for us...
相关标签:
PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号