/ Published in: PHP
URL: http://e-commsolution.com
Expand |
Embed | Plain Text
// paging code // Query to count rows. $items = 32; // number of items per page. $all = $_GET['a']; if($all == "all"){ $items = $num_rows; } $nrpage_amount = $num_rows/$items; $page_amount = $page_amount-1; if($page < "1"){ $page = "0"; } $p_num = $items*$page; //end paging code // Query that you would like to SHOW $result = mysql_query("SELECT * FROM Table_Name WHERE Column_Name = '$section' ORDER BY 'name' ASC LIMIT $p_num , $items"); function paging(){ global $num_rows; global $page; global $page_amount; global $section; if($page_amount != "0"){ echo "<div class=paging>"; if($page != "0"){ $prev = $page-1; echo "<a href=\"section.php?q=$section&p=$prev\">Prev</a>"; } for ( $counter = 0; $counter <= $page_amount; $counter += 1) { echo "<a href=\"section.php?q=$section&p=$counter\">"; echo "</a>"; } if($page < $page_amount){ $next = $page+1; echo "<a href=\"section.php?q=$section&p=$next\">Next</a>"; } echo "<a href=\"section.php?q=$section&a=all\">View All</a>"; echo "</div>"; } } // call on Pagination with function paging();
Comments
Subscribe to comments
You need to login to post a comment.

What's the a in $all = $GET['a']; and the p in $page = mysqlrealescapestring($_GET['p']); supposed to be?
That is the "View All" pram and it is escaped to prevent MySQL injection.