| <body> ? 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. " Record <br>n "); $recordperpage = 15; How many records are displayed per page $pages =ceil ($rowcount/$recordperpage); Total pages Echo ("Shared". $pages. " Page <br>n "); ?> <table border=0><tr><td>id</td><td>name</td></tr> ? Determine if the offset parameter is passed to the script, and if not, use the default value 0 if (empty ($offset)) { $offset = 1; } $currentpage =ceil ($offset/$recordperpage); Show Current Page Echo ("Current page:". $currentpage. " <br>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. "Minus select Id,name from Xqhtest where rownum<." $offse T. " <br>n "; Ociexecute ($stmt 2); can be any SQL statement, but there must be rownum behind the Select, which is unique to Oracle! while (Ocifetch ($stmt 2)) { Echo ("<tr><td>". Ociresult ($stmt 2, "ID"). " </td><td> ". Ociresult ($stmt 2," NAME ")." </td></tr>n "); For the code you used to display the return record. } To write a link to all pages print "</table><br><br>"; for ($i =1; $i <= $pages; $i + +) { $newoffset = ($recordperpage * ($i-1)) +1; Print "<a href=" $PHP _self?offset= $newoffset "> $i </a> n"; } print "<br>"; $nextoffset = $recordperpage * $currentpage +1; $prevoffset = $recordperpage * ($currentpage-2) +1; Determine if a previous page connection is required if ($currentpage >1) && ($currentpage <= $pages)) { Print "<a href=" $PHP _self?offset= $prevoffset "> Prev </a> n"; } |