whiteboikyle Posted June 18, 2008 Share Posted June 18, 2008 Okay well i made a full automative page number.. If i put ?page=1 it will display the first 20 (1-20) then if i put ?page=2 it will display the next 20 (21-40) but i want to make page numbers at the bottom that calculate from the numbers of members and the certain amount of page's. So here is my code function.php <?php function member_start($page) { if($page < 1) { $error = "Number must be greater then 0!"; return $error; } $number = ($page * 20)-19; return $number; } ?> members.php <?php include("header.inc"); if(isset($_GET['page'])) { $page = $_GET['page']; if(is_numeric($_GET['page'])) { $number = member_start($page); $result = $config->query("SELECT * FROM members ORDER BY id limit $number, 20"); while( $row = mysql_fetch_array($result) ) { echo("<a href='http://www.corpaluploads.com/".$row['username']."' class='members'>".$row['username']."</a> <a href='http://www.corpaluploads.com/".$row['username']."'>http://www.corpaluploads.com/".$row['username']."</a><br />"); } } else { echo "Only Numeric Data May Be Entered!"; } } else { $number = member_start(1); $result = $config->query("SELECT * FROM members ORDER BY id limit $number, 20"); while( $row = mysql_fetch_array($result) ) { echo("<a href='http://www.corpaluploads.com/".$row['username']."' class='members'>".$row['username']."</a> <a href='http://www.corpaluploads.com/".$row['username']."'>http://www.corpaluploads.com/".$row['username']."</a><br />"); } } include("footer.inc"); ?> Link to comment https://forums.phpfreaks.com/topic/110673-solved-page-number-automative/ Share on other sites More sharing options...
whiteboikyle Posted June 18, 2008 Author Share Posted June 18, 2008 Solved it function page_numbers($members) { $number = $members/20; if(is_int($number)) { for ($i=0;$i<$number;$i++) { echo("<a href='?page=".$i."'>$i</a>"); } } else { $number = floor($number); $number = $number + 2; for ($i=0;$i<$number;$i++) { if($i == 0) { continue; } echo("<a href='?page=".$i."'>$i </a>"); } } } memebers.php $result = $config->query("SELECT * FROM members"); $members = mysql_num_rows($result); echo("<br><br><div align='center'>Page: "); page_numbers($members); echo(" </div>"); Link to comment https://forums.phpfreaks.com/topic/110673-solved-page-number-automative/#findComment-567780 Share on other sites More sharing options...
DarkWater Posted June 18, 2008 Share Posted June 18, 2008 You're welcome. =P (Lol, MSN) Link to comment https://forums.phpfreaks.com/topic/110673-solved-page-number-automative/#findComment-567782 Share on other sites More sharing options...
whiteboikyle Posted June 18, 2008 Author Share Posted June 18, 2008 is there a way to +rep? Link to comment https://forums.phpfreaks.com/topic/110673-solved-page-number-automative/#findComment-567789 Share on other sites More sharing options...
DarkWater Posted June 18, 2008 Share Posted June 18, 2008 I wish. D: Link to comment https://forums.phpfreaks.com/topic/110673-solved-page-number-automative/#findComment-567792 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.