Adding Pagination to my PHP Script

I have tried multiple different methods, but I cant seem to add pagination to this script…

<?php
include ("../includes/config.php");
$chardb_connect = mysql_connect($chardb_host,$chardb_user,$chardb_pass) OR DIE("Cant connect with $chardb_host");
mysql_select_db($chardb_name, $chardb_connect) or die(mysql_error());
$var_guild = (isset($_GET['guild_id'])) ? $_GET['guild_id'] : '';
$order = (isset($_GET['order'])) ? $_GET['order'] : 'cname';
$sorting = (isset($_GET['sorting'])) ? $_GET['sorting'] : 'desc';
switch($sorting) {
case "asc":
$sort = 'desc';
break;
case "desc":
$sort = 'asc';
break;
}
$query = "SELECT characters.name AS cname, characters.level AS clevel, characters.race AS crace, characters.gender AS cgender, characters.class AS cclass, characters.online AS conline, guild.name AS gname, guild.guildid AS gid
FROM characters AS characters
LEFT JOIN guild_member AS guild_member ON guild_member.guid = characters.guid
LEFT JOIN guild AS guild ON guild.guildid = guild_member.guildid
WHERE guild_member.guid = characters.guid AND guild_member.guildid = $var_guild ORDER BY $order"." $sort";
$result = mysql_query($query) or die(mysql_error());
?>
<table align=center cellpadding="1" cellspacing="1"  border="1">
<thead>
<td><a href="characters_guild.php?guild_id=<?=$var_guild;?>&order=cname&sorting=<?=$sort;?>">Character</a></td>
<td><a href="characters_guild.php?guild_id=<?=$var_guild;?>&order=clevel&sorting=<?=$sort;?>">Level</a></td>
<td><a href="characters_guild.php?guild_id=<?=$var_guild;?>&order=crace&sorting=<?=$sort;?>">Race</a></td>
<td><a href="characters_guild.php?guild_id=<?=$var_guild;?>&order=cclass&sorting=<?=$sort;?>">Class</a></td>
<td><a href="characters_guild.php?guild_id=<?=$var_guild;?>&order=conline&sorting=<?=$sort;?>">Online</a></td>
</thead>
<tbody>
<?php
while($row = mysql_fetch_object($result))
{
$char_name = $row->cname;
$char_level = $row->clevel;
$char_race = $row->crace;
$char_gender = $row->cgender;
$char_class = $row->cclass;
$char_online = $row->conline;
$guild_name = $row->gname;
$guild_id = $row->gid;
echo "<tr>";
echo "<td>",$char_name,"</td>";
echo "<td>",$char_level,"</td>";
echo " <td><center><img src='../images/race/small/" . $char_race . "-" . $char_gender . ".gif'></center></td>";
echo " <td><center><img src='../images/class/small/" . $char_class . ".gif'></center></td>";
if($char_online == 0) {
echo " <td><center><img src='../images/base/ofl_button.png'></center></td>";
} else {
if($char_online == 1) {
echo " <td><center><img src='../images/base/onl_button.png'></center></td>";
}	}
echo "</tr>";
}
?>

Any suggestions would be greatly appreciated!
Thank you in advance!

Sponsor our Newsletter | Privacy Policy | Terms of Service