|
-
Oct 15th, 2012, 03:49 PM
#1
Thread Starter
Lively Member
Paginate MYSQL Table
I've never really done this, and Im kinda stuck on it. Can anyone help me on how to paginate this table, with it only showing 10 results at a time.
PHP Code:
echo "<table border='1'>
<tr>
<th>Rank</th>
<th>Name</th>
<th>Level</th>
<th>Fame</th>
<th>Job</th>
</tr>";
$number = 1;
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $number; $number = $number+1 . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['level'] . "</td>";
echo "<td>" . $row['fame'] . "</td>";
echo "<td>" . $jobs[$row['job']] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($con);
?>
-
Oct 15th, 2012, 08:29 PM
#2
Re: Paginate MYSQL Table
Use a LIMIT on your query to set upper and lower boundaries to the results.
-
Oct 16th, 2012, 01:11 AM
#3
Thread Starter
Lively Member
Re: Paginate MYSQL Table
 Originally Posted by penagate
Use a LIMIT on your query to set upper and lower boundaries to the results.
Already have that, but that doesn't help me on knowing how to paginate it. I've never done it before, and there aren't really any good tutorials that I can find.
PHP Code:
$result = mysql_query("SELECT * FROM Characters WHERE gm=0 ORDER BY Level DESC LIMIT 100");
Incase you wanted it.
Last edited by Marthz; Oct 16th, 2012 at 01:31 AM.
-
Oct 16th, 2012, 05:21 AM
#4
Re: Paginate MYSQL Table
 Originally Posted by Marthz
Already have that, but that doesn't help me on knowing how to paginate it. I've never done it before, and there aren't really any good tutorials that I can find.
PHP Code:
$result = mysql_query("SELECT * FROM Characters WHERE gm=0 ORDER BY Level DESC LIMIT 100");
Incase you wanted it.
Marthz, you are missing the point. See this:
 Originally Posted by penagate
Use a LIMIT on your query to set upper and lower boundaries to the results.
Check this tutorials: http://www.phpeasystep.com/phptu/29.html
It is written using legacy mysql_* functions. After you get the idea, rewrite it using mysqli or PDO. And always avoid mysql_* functions.
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|