Previous and Next
Posted: Mon Mar 06, 2006 3:20 pm
The code below is not working for me on this new server, but on another server the same code works, do I need to change how I call my variables?
My problem is basically when you click the "Next 5 Users" it does not reconize that $offset has changed, the program still reconizes $offset as 0.
My problem is basically when you click the "Next 5 Users" it does not reconize that $offset has changed, the program still reconizes $offset as 0.
Code: Select all
<table width="350" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center">CHANGE USER INFORMATION</td>
</tr>
<?php
if($offset == "") {
$offset = "0";
}
$limit = "5";
$result = mysql_query("SELECT * FROM users ORDER BY id DESC LIMIT $offset,$limit");
while($row = mysql_fetch_array($result)) {
?>
<form method="post" action="executive.php?cmd=change_a_user">
<input type="hidden" name="id" value="<?php echo $row["id"]; ?>">
<tr>
<td><?php echo $row["username"]; ?></td>
<td><input type="submit" name="change" value="Change" class="buttons"></td>
</tr>
</form>
<?php
}
?>
<tr>
<?php
if($offset == "0") {
?>
<td>« Previous 5 Users</td>
<?php
} else {
?>
<td>« <a href="executive.php?cmd=change_a_user&limit=<?php echo $limit; ?>&offset=<?php echo $offset - "5"; ?>">Previous 5 Users</a></td>
<?php
}
if(mysql_num_rows($result) == $row["id"]) {
?>
<td>Next 5 Users » </td>
<?php
} else {
?>
<td><a href="executive.php?cmd=change_a_user&limit=<?php echo $limit; ?>&offset=<?php echo $limit + "5"; ?>">Next 5 Users</a> »</td>
<?php
}
?>
</tr>
</table>