I have no idea how to do this...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Monotoko
Forum Commoner
Posts: 64
Joined: Fri Oct 26, 2007 4:24 pm

I have no idea how to do this...

Post by Monotoko »

i will give you a snippit of my code, to help you visualize my problem.

Code: Select all

 
elseif ($action == 'members')
{
echo "<table class='tborder' cellpadding='6' cellspacing='1' border='0' width='100%'
style='border-bottom-width:0px'>
<tr>
    <td class='tcat' width='100%'>
        <div align='center'>Members List</div></td>
    
</tr>
</table>
<table class='tborder' cellpadding='6' cellspacing='1' border='0' width='100%' align='center'>
<tr>
    <td class='alt1'><p align='center'><table border='1'>
<tr>
<td>Member</td>
<td>Gamers Level</td>
<td>Group</td>
<td>Clan</td>
<td>Joined</td>
<td>Posts</td>
<td>email</td>
</tr>
<tr>";
 
$newshome = mysql_query("SELECT * FROM members");
 
while($row = mysql_fetch_array($newshome))
{
$name = $row['username'];
$lvl = $row['level'];
$group = $row['group'];
$email = $row['email'];
$clan = $row['clan'];
$posts = $row['posts'];
$joined = $row['joined'];
 
echo "<tr>
<td>$name</td>
<td>$lvl</td>
<td>$clan</td>
<td>$group</td>
<td>$joined</td>
<td>$posts</td>
<td>$email</td>
</tr>";
}
echo "</table>
<br />
    </p>
      </td>
</tr>
</table>";
}
 
At the moment it just displays a never ending list of members, all on one page, and it can often be a pain to load.
Instead, what i want it to do is display 20 members on each page using the $_GET function

for example:
http://www.example.com/index.php?action=members&page=1
i want that to display members 1-20

whereas i want the following to display members 41-60
http://www.example.com/index.php?action=members&page=3

Thanks guys, i know im probably missing something simple here, but i just cant think today for some reason and its been making me :banghead: for hours XD
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: I have no idea how to do this...

Post by Christopher »

Search these forums for "pagination". Also I think there are some examples in Code Snippets.
(#10850)
Post Reply