freshteh Posted January 10, 2008 Share Posted January 10, 2008 I want to create in end of page same this: 1 2 3 ... that with click on ... go to 4 5 6 ... Plese help me. Thank you very much ??? Link to comment https://forums.phpfreaks.com/topic/85354-page-counter/ Share on other sites More sharing options...
JJohnsenDK Posted January 10, 2008 Share Posted January 10, 2008 plz explain yourself a bit better... i dont understand what you want to do? Link to comment https://forums.phpfreaks.com/topic/85354-page-counter/#findComment-435492 Share on other sites More sharing options...
nezbo Posted January 10, 2008 Share Posted January 10, 2008 if you are after a pages system. i have made an easy way. Here is the codes:: creat a file called pages.php and past the following in it : <!-- A header should be here so that the text works --> <?php echo "<div align=center>"; $display = 20; if (isset($_REQUEST["np"])) { $num_pages = $_REQUEST["np"]; } else { $query2 = "SELECT COUNT(*) FROM $table $whereCond $whereCond2 ORDER BY $orderBy $asc_desc" or die("oh dear" . mysql_error()); $result2 = mysql_query($query2); $row2 = mysql_fetch_array($result2, MYSQL_NUM); $num_records = $row2[0]; } if ($num_records > $display) { $num_pages = ceil ($num_records/$display); } else { $num_pages = 1; } if (isset($_GET["s"])) { $start = $_GET["s"]; } else { $start = 0; } if ($num_pages > 1) { $current_page = ($start/$display) + 1; if ($current_page != 1) { echo "<a href=\"?s=" . ($start - $display) . "&w=" . $find . "\">Previous</a> "; } for ($i = 1; $i <= $num_pages; $i++) { if($i != $current_page) { echo "<a href=\"?s=" . ($display * ($i - 1)) . "&w=" . $find . "\">" . $i . "</a> "; } else { echo $i . " "; } } if ($current_page != $num_pages) { echo "<a href=\"?s=" . ($start + $display) . "&w=" . $find . "\">Next</a>"; } } echo "</div><br />"; ?> then where you want your pages past this code:: $table = "t1"; $whereCond = ""; //WHERE xxxx = 'xxxx'; $whereCond2 = ""; //AND/OR xxxx = 'xxxx'; $orderBy = ""; $asc_desc = ""; $result = mysql_query("SELECT * FROM $table $whereCond $whereCond2 ORDER BY $orderBy $asc_desc LIMIT $start, $display")or die(mysql_error()); Hope this helps... Link to comment https://forums.phpfreaks.com/topic/85354-page-counter/#findComment-435504 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.