Working Pagination?

Posted on Sunday 2nd September 2007 at 08:47 PM
Diablosblizz
Diablosblizz's Avatar
Anybody got? Simple enough so I can put it into my recoded members.php??

Thanks.
Posted on Sunday 2nd September 2007 at 09:21 PM
Posted on Monday 3rd September 2007 at 01:36 AM
Diablosblizz
Diablosblizz's Avatar
Doesn't work. I already told Shadow.
Posted on Friday 5th October 2007 at 07:05 PM
paradox
paradox's Avatar
this is what im using. it works with no probs. and also has alternating row colors. you may need to edit some things to make it work with rmb's usersystem but i have changed some of it already.


echo"<table>";
if($_GET['num']) // Is page defined?
{
$page = $_GET['num']; // Set to the page defined
}else{
$page = 1; // Set to default page 1
}
$max = 20; // Set maximum to 10

$cur = (($page * $max) - $max); // Work out what results to show

$getdata = mysql_query("SELECT * FROM `members` ORDER BY `id` ASC LIMIT $cur, $max") or die(mysql_error()); // select the results
while($row = mysql_fetch_array($getdata)){
if ($bgcolor == "#ffffff"){
$bgcolor = "#cccccc";
}else{
$bgcolor = "#ffffff";
}
echo"<tr bgcolor=".$bgcolor."><td width='30%'>";
echo"<a href='members.php?user=$row[username]'>$row[username]</a>";
echo"</td><td width='50%'>";
echo"$row[email]";
echo"</td><td width='20%'>";
echo"$row[joindate]";
echo"</td></tr>";
}

$counttotal = mysql_query("SELECT * FROM `members` ") or die(mysql_error()); // select all records

$counttotal = mysql_num_rows($counttotal); // count records

$total_pages = ceil($counttotal / $max); // dive the total, by the maximum results to show
echo"</table><center>";
if($page > 1){ // is the page number more than 1?
$prev = ($page - 1); // if so, do the following. take 1 away from the current page number
echo '<a href="members.php&num=' . $prev . '">« Previous</a> '; // echo a previous page link
}
for($i = 1; $i <= $total_pages; $i++) // for each page number

{

if($page == $i) // if this page were about to echo = the current page

{

echo' '. $i .' '; // echo the page number bold

} else {

echo '<a href="members.php&num=' . $i . '">' . $i . '</a>'; // echo a link to the page

}

}

if($page < $total_pages){ // is there a next page?

$next = ($page + 1); // if so, add 1 to the current

echo ' <a href="members.php&num=' . $next . '">Next »</a>'; // echo the next page link

}
echo"</center>";

if any probs let me know.
Tehleetness
Login or register to respond to this forum topic.