Please.....Pagination
Hi, I want craete a page that can list of record in html format. Let say the query may result in hundreds or thousands of records. Then, I need create button PREV and NEXT.
1. Isn't I need to create a procedure and run at SQL* Plus, i.e.
create or replace procedure paginate( p_start in number default 1)
as
l_next boolean default false;
l_pagesize number default 50;
begin
htp.bold( 'p_start =' || P_start);
htp.p('<table>');
for x in (select *
from (select a.*, rownum r from bill a
where rownum <= p_start+l_pagesize) a
where r >= p_start)
loop
l_next :=( x.r = p_start=l_pagesize);
htp.p( '<tr><td>' || x.r || '</td><td>' ||
x.invno || '</td></tr>');
end loop;
htp.p( '</table>');
if( p_start >1)
then
htp.formOpen( 'paginate');
htp.formHidden( 'p_start', p_start-l_pagesize);
htp.formSubmit( cvalue => 'prev' || (p_start-l_pagesize));
htp.formClose;
end if;
if(l_next)
then
htp.formOpen( 'paginate');
htp.formHidden( 'p_start', (p_start+l_pagesize));
htp.formSubmit( cvalue => 'next' || (p_start+l_pagesize));
htp.formClose;
end if;
end;
/
Are this code write in correctly? Do have duplicate record?
2. After I have create a procedure, how I want apply this in my application code(PHP)?
i.e.
<html>
.....
<?php
require_once("DB.php");
$connection = OCILogon("prod", "prod");
$stmt = OCIParse($connection, "SELECT * FROM ( SELECT a.*, rownum rnum
FROM (SELECT invno FROM bill ORDER BY invno) a
WHERE rownum < 50)
WHERE rnum >= 1 ");
OCIExecute($stmt);
$rownum = OCIFetchStatement( $stmt, $results);
//display all entries
for ( $i=0; $i<$rownum; $i++ )
{
echo " <td class=text8Arial11> " .$results["INVNO"][$i]."</td>";
echo "</tr>";
}
OCILogOff($connection);
?>
.....
</html>
3. Should I need create a button PREV and NEXT links in <html> tag?i.e.
<a href="javascript:doSubmit_prev();">Previous 50 Records</a>
<a href="javasrcipt:doSubmit_next();">Next 50 Records</a>
Then, where should I POST this form method each time I click the button NEXT / PREV?
4. If this more complicate way, are there have other more easier and understanding solution way to solve it?
Please...
Thanks in advance.
Oracle 8.1.7
PHP 4.3.4
Apache / IIS webserver
Win2000
|