Jump to content

Deleteing MySQL rows with PHP


OneEyedWillie

Recommended Posts

Hi, I'm trying to create a page where we can remove bans from the MySQL database. I've come up with this so far, but need some help.

 

	
<form method="post" action="viewbans.php" name="managebans">
<table width="100%" border="1">
<tr>
<td>Remove?</td>
<td>IP</td>
<td>Username</td>
<td>Reason</td>
</tr>
<?php
mysql_connect("localhost", "islewar", "islewar") or die(mysql_error());
mysql_select_db("islewar") or die(mysql_error());

$result = mysql_query("select * from bans") or die(mysql_error());
while($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td><input type=checkbox name=ban />";
echo "</td>";
echo "<td>";
echo $row['ip'];
echo "</td><td>";
echo $row['username'];
echo "</td><td>";
echo $row['reason'];
echo "</td>";
echo "</tr>";
}
?>
</table>
<input type="submit" name="delete" value="Remove Bans" />
</form>

 

It reads the data from the database and shows it on the screen correctly. I just can't get the checkboxes to delete when they are selected,

 

Thanks :)

Link to comment
https://forums.phpfreaks.com/topic/238677-deleteing-mysql-rows-with-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.