i\'m writing my own news script using php and mysql. but i have hit a problem. when i try to delete one entry they all get deleted. i know where the problem is but i don\'t know how to fix it. what happens is when you want to delete a entry you tick a checkbox next to the entry you want to get rid of and it should be deleted. but the php/mysql is setup so that the checkbox on the form are named after the mysql database id. that id number isn\'t sent to mysql when the delete request is made so all the entrys are deleted.
the relevant code is attached. any help is appreciated.
this is the delete form
<form action="delete_notice.php" method="post">
$query = "SELECT title, id FROM notices";
$result = mysql_query($query);
$numrows = mysql_num_rows($result);
while($row = mysql_fetch_array($result)){
?> <input name="<? echo "$row[id]"; ?>" type=checkbox> <? echo "$row[title]";
print \'<br>\';
}
?>
<br>
<input type="submit" value="Delete selected">
</form>
and this is the query that deletes the entries (named delete_notice.php)
$id = $_POST[\'id\'];
$link = mysql_connect("localhost", $dbuser, $dbpass) or die ("Database Error: Couldn\'t Connect!");
mysql_select_db($dbname, $link) or die ("Couldn\'t open $dbname!");
$query = "DELETE FROM notices WHERE \'id\' = \'$id\' ";
mysql_query($query, $link) or die ("Couldn\'t delete data!");
mysql_close($link);
include "header.php";
print \'<center>\';
print \'<br>\';
print \'Notice(s) succesfully deleted\';
print \'<br>\';
print \'<a href="noticeadmin.php">Return to Notices Administration</a>\';
print \'<center>\';
the table that is being accesed is notice and the fields are id (auto-incrementing id no.), title and notice.
i missed out the mysql connect stuff becuase that is ok.
many thanx