HOME

Share

Paging Function In PHP

Discussion about PHP

Moderator: darz

Paging Function In PHP

Postby darz on Wed Jul 30, 2008 5:23 pm

Paging in PHP is an important one. Here is the sample code for it. Thinks this may help you.

1) First find the total count of records.
2) Set the total records per page.
3) Third parameter as page index.

Then call the php paging function by passing the above values as parameter
s.

function display_page_links($cur_page,$num_rows,$rows_per_page){
$last_page_no = ceil($num_rows/$rows_per_page);
$link_str = "";
for($i=1; $i<=$last_page_no; $i++):
$link_str .= " ";
if($i==$cur_page):
$link_str .= $i;
else:
$link_str .= "<a href='index.php?cur_page=$i&num_rows=$num_rows' target='_self'>$i</a>";
endif;
$link_str .= " ";
endfor;
echo $link_str;
return;
}
Thankz N Regz...
Darz

Image
User avatar
darz
 
Posts: 18
Joined: Mon Jun 23, 2008 9:16 am

Return to PHP

Who is online

Users browsing this forum: No registered users and 1 guest

cron