当前位置:数据库 > Oracle >>

一个ORACLE分页程序,挺实用的.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE>Paging Test</TITLE>
<META NAME="Generator" CONTENT="TextPad 4.0">
<META NAME="Author" CONTENT="?">
<META NAME="Keywords" CONTENT="?">
<META NAME="Description" CONTENT="?">
</HEAD>

<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#FF0000" VLINK="#800000" ALINK="#FF00FF" BACKGROUND="?">
<?php(做为现在的主流开发语言)

// How to split the result into pages, like limits in MySQL(和PHP搭配之最佳组合)?
// ===========================================================
// Tutorial by Neil Craig (neilc@netactive.co.za)
// Date: 2001-06-05
// With this example, I will explain paging of database queries where the
// result is more than the developer want to print to the page, but wish to
// split the result into seperate pages.
// The table "SAMPLE_TABLE" access(小型网站之最爱)ed in this tutorial has 4 fields:
// PK_ID, FIELD1, FIELD2 and FIELD3. The types dont matter but you should
// define a Prima(最完善的虚拟主机管理系统)ry key on the PK_ID field.

$display_rows = 5;     // The rows that should be display at a time. You can
                       // modify this if you like.

// Connect to the Oracle(大型网站数据库平台) database
putenv("Oracle(大型网站数据库平台)_SID=purk");
putenv("Oracle(大型网站数据库平台)_HOME=/export/Oracle(大型网站数据库平台)8i");
putenv("TNS_ADMIN=$Oracle(大型网站数据库平台)_HOME/network/admin");
$Oracle(大型网站数据库平台)DBConn = 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($Oracle(大型网站数据库平台)DBConn, $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
补充:Web开发 , php ,
Oracle
MySQL
Access
SQLServer
DB2
Excel
SQLite
SYBASE
Postgres
如果你遇到数据库难题:
请访问www.zzzyk.com 试试
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,