How do you make multiple pages in PHP? EG/. If i made a page that shows all users that have registered, how would i make it show 30 on the page and then 30 on each other page but on the same script like PAGE.PHP?Page=2 Cheers
- by using paging someone wrote a code recenlty here ... about paging ... or just search "paging php" in google
its farily simple but takes a while to make a function. Use the sql offset and limit commands will help. Just google it, also look around the forums, there are similar threads regarding this topic.
<?php $num_per_page = "10"; $page = $_REQUEST['page']; if($page==NULL){ $page = 1; } $numrows = mysql_num_rows(mysql_query("SELECT * FROM tablename")); $start = $page * $num_per_page; $sql = mysql_query("SELECT * FROM tablename LIMIT $start,$num_per_page"); while($r=mysql_fetch_assoc($sql)){ echo "put output php stuff here"; } $pages = $numrows/$num_per_page; $prev = $page - 1; $next = $page + 1; echo "<a href=\"?page=1\">First</a>"; echo "<a href=\"?page=".$prev."\">Prev</a>"; for($i=0;$i<=$pages;$i++){ if($i==$page){ echo "<a href=\"?page=".$i."\">[".$i."]</a>"; }else{ echo "<a href=\"?page=".$i."\">".$i."</a>"; } } echo "<a href=\"?page=".$next."\">Next</a>"; echo "<a href=\"?page=".$pages."\">Last</a>"; ?> PHP: its a little glitchy but thats the idea behind it