Include "/maya/inc/dbconn.php"; $sql = "Select Max (rownum) from xqhtest where id<50"; $stmt =ociparse ($gConn, $sql); Ociexecute ($stmt); Ocifetch ($stmt); $rowcount =ociresult ($stmt, 1); Ocifreestatement ($stmt); Echo ("Shared". $rowcount. " Article Records n "); $recordperpage = 15; How many records are displayed per page $pages =ceil ($rowcount/$recordperpage); Total pages Echo ("Shared". $pages. " Page n ");
?>
Determines whether the offset parameter is passed to the script, and if not, uses the default value of 0 if (empty ($offset)) { $offset = 1; } $currentpage =ceil ($offset/$recordperpage); Show Current Page Echo ("Current page:". $currentpage. " n "); $endset = $offset + $recordperpage; $stmt 2=ociparse ($gConn, "select Rownum,id,name from Xqhtest WHERE id<50 and rownum<". $endset. "Minus Select RowNum, Id,name from Xqhtest where id<50 and rownum< ". $offset); echo "Select Id,name from Xqhtest where rownum<". $endset. "The minus select Id,name from Xqhtest where rownum<". $offse T. " n "; Ociexecute ($stmt 2); can be any SQL statement, but there must be rownum behind Select, which is unique to Oracle! while (Ocifetch ($stmt 2)) { Echo (" Replace the code you used to display the return record } To write a link to all pages Print "
| Id |
Name |
| ". Ociresult ($stmt 2," ID ")." |
". Ociresult ($stmt 2," NAME ")." |
n ");
"; for ($i =1; $i <= $pages; $i + +) { $newoffset = ($recordperpage * ($i-1)) +1; print "$i n"; } Print " ";
$nextoffset = $recordperpage * $currentpage +1; $prevoffset = $recordperpage * ($currentpage-2) +1; Determine if a previous page connection is required if ($currentpage >1) && ($currentpage <= $pages)) { print "Prev n"; } |