bucket
11-03-2009, 06:02 PM
Can someone add a limit function to this, kind of like a pagination?
Like after 5 it makes it stop and you have to go another page like page.php?page=2
something like that.
code:
<?php
require("inc/config.php");
if (isset($_POST['del']))
{
for ($count = 0;$count<count($_POST[delchk]);$count++)
{
$delete = $_POST[delchk][$count];
$query = "DELETE FROM accounts WHERE id = '$delete'";
$result = mysql_query($query);
if (!$result)
{
die("Error deleting accounts! Query: $query<br />Error: ".mysql_error());
}
}
}
$result = mysql_query("SELECT * FROM accounts");
// Check how many rows it found
if(mysql_num_rows($result) > 0){
echo "<h2>Logged Account Details</h2>";
echo "<table class=\"gridtable\">
<thead>
<tr>
<th align=\"center\" scope=\"col\">Delete?</th>
<th align=\"center\" scope=\"col\">Username</th>
<th align=\"center\" scope=\"col\">Password</th>
<th align=\"center\" scope=\"col\">Highscores</th>
<th align=\"center\" scope=\"col\">Date</th>
<th align=\"center\" scope=\"col\">IP Address</th>
<th align=\"center\" scope=\"col\">Status</th>
</tr>
</thead>
<tbody>";
echo "<form name = 'myform' action='' method='post'>";
while($row = mysql_fetch_array($result))
{
echo "<tr align=\"center\">";
echo '<td><input type="checkbox" id="delchk" name="delchk[]" value="'.$row['id'].'" /></td>';
echo "<td class=\"valid\" >" . $row['username'] . "</td>";
echo "<td class=\"valid\" >" . $row['password'] . "</td>";
echo "<td><a target=frame2 href='" ."http://hiscore.runescape.com/hiscorepersonal.ws?user1=". $row['username'] ."'>Check Highscores</a></td>";
echo "<td>" . $row['addeddate'] . "</td>";
echo "<td>" . $row['ip'] . "</td>";
echo "<td><img src=\"img/invalid.png\" title=\"Account information: INVALID!\"/><img src=\"img/valid.png\" title=\"Account information: VALID!\"/></td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
echo "<hr>";
echo "<input type='submit' name = 'del' value='Delete Selected'></form>";
echo "<input type='button' onclick='checkall(document.myform[\"delchk\"]);' value='Select All'>";
echo "<input type='button' onclick='uncheckall(document.myform[\"delchk\"]);' value='Deselect All'>";
echo "<hr>";
}
else{
// No rows were found ...
echo '<center>No logged accounts.</center><hr>';
}
mysql_close();
?>
Thank You.
Like after 5 it makes it stop and you have to go another page like page.php?page=2
something like that.
code:
<?php
require("inc/config.php");
if (isset($_POST['del']))
{
for ($count = 0;$count<count($_POST[delchk]);$count++)
{
$delete = $_POST[delchk][$count];
$query = "DELETE FROM accounts WHERE id = '$delete'";
$result = mysql_query($query);
if (!$result)
{
die("Error deleting accounts! Query: $query<br />Error: ".mysql_error());
}
}
}
$result = mysql_query("SELECT * FROM accounts");
// Check how many rows it found
if(mysql_num_rows($result) > 0){
echo "<h2>Logged Account Details</h2>";
echo "<table class=\"gridtable\">
<thead>
<tr>
<th align=\"center\" scope=\"col\">Delete?</th>
<th align=\"center\" scope=\"col\">Username</th>
<th align=\"center\" scope=\"col\">Password</th>
<th align=\"center\" scope=\"col\">Highscores</th>
<th align=\"center\" scope=\"col\">Date</th>
<th align=\"center\" scope=\"col\">IP Address</th>
<th align=\"center\" scope=\"col\">Status</th>
</tr>
</thead>
<tbody>";
echo "<form name = 'myform' action='' method='post'>";
while($row = mysql_fetch_array($result))
{
echo "<tr align=\"center\">";
echo '<td><input type="checkbox" id="delchk" name="delchk[]" value="'.$row['id'].'" /></td>';
echo "<td class=\"valid\" >" . $row['username'] . "</td>";
echo "<td class=\"valid\" >" . $row['password'] . "</td>";
echo "<td><a target=frame2 href='" ."http://hiscore.runescape.com/hiscorepersonal.ws?user1=". $row['username'] ."'>Check Highscores</a></td>";
echo "<td>" . $row['addeddate'] . "</td>";
echo "<td>" . $row['ip'] . "</td>";
echo "<td><img src=\"img/invalid.png\" title=\"Account information: INVALID!\"/><img src=\"img/valid.png\" title=\"Account information: VALID!\"/></td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
echo "<hr>";
echo "<input type='submit' name = 'del' value='Delete Selected'></form>";
echo "<input type='button' onclick='checkall(document.myform[\"delchk\"]);' value='Select All'>";
echo "<input type='button' onclick='uncheckall(document.myform[\"delchk\"]);' value='Deselect All'>";
echo "<hr>";
}
else{
// No rows were found ...
echo '<center>No logged accounts.</center><hr>';
}
mysql_close();
?>
Thank You.