PHP Code:
<form>
<?php
$query = "SELECT *
FROM store
ORDER BY TIME DESC";
$result = mysql_query($query, $connection);
if (!$result) {
die("Database query failed: " . mysql_error());
}
echo '<br /><b><u>LATEST UPLOADS:</u></b><br /><br />';
echo '<table border=1 align=center cellpadding=5>';
echo '<tr><th>URL OF UPLOAD</th><th>FROM IP</th><th>TIME</th>';
echo '<th><input name="delete" type="submit" id="delete" value="Delete" method="POST"></th></tr>';
while ($row = mysql_fetch_array($result))
{
$link = "../".$row["url"];
echo "<tr>";
echo "<td><a href='{$link}'>{$row["url"]}</a></td>";
echo "<td>{$row["IP"]}</td>";
echo "<td>{$row["TIME"]}</td>";
echo "<td><input type=\"checkbox\" name=\"checkbox[]\" id=\"checkbox[]\" value=\"{$row["id"]}\" /></td>";
echo '</tr>';
}
if(isset($_POST['delete']))
{
if (count($_POST['checkbox']) > 0) {
foreach ($_POST['checkbox'] as $del_id) {
$sql = "DELETE FROM store WHERE id=' " . $del_id . " ' ";
$result = mysql_query($sql) or die(mysql_error());
if(mysql_affected_rows($result) > 0) echo 'Selected data rows Deleted';
}
}
}
?>
</form>
i've gotta fiddle with the last chunk of code, somethings not right there since nothings being deleted.
Bookmarks