jr_cumbo Posted October 12, 2007 Share Posted October 12, 2007 Hi, I have made is script i need it to delete the id's of the one's checked. The variables all contain the correct values and the $result = true, but it seems like its not sending the query. It connects to the database correctly, because it displays the rows in the table. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Edit Events</title> </head> <body> <?php require_once('../Connections/DB_HTF.php'); ?> <?php mysql_select_db($database_DB_HTF, $DB_HTF); $query_select_events = "SELECT * FROM events"; $select_events = mysql_query($query_select_events, $DB_HTF) or die(mysql_error()); $totalRows_select_events = mysql_num_rows($select_events); ?> <tr> <td><form name="delete_events" method="post" action=""> <table width="400" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td height="63" bgcolor="#FFFFFF"> </td> <td colspan="4" bgcolor="#FFFFFF"><strong>Delete from events</strong> </td> </tr> <tr> <td align="center" bgcolor="#FFFFFF">#</td> <td align="center" bgcolor="#FFFFFF"><strong>Id</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Event</strong></td> <td align="center" bgcolor="#FFFFFF"><strong>Date</strong></td> </tr> <?php while($row_select_events = mysql_fetch_assoc($select_events)){ ?> <tr> <td align="center" bgcolor="#FFFFFF"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?php echo $row_select_events['event_id']; ?>"></td> <td bgcolor="#FFFFFF"><?php echo $row_select_events['event_id']; ?></td> <td bgcolor="#FFFFFF"><?php echo $row_select_events['event_desc']; ?></td> <td bgcolor="#FFFFFF"><?php echo $row_select_events['event_date']; ?></td> </tr> <?php } ?> <tr> <td colspan="5" align="center" bgcolor="#FFFFFF"><input name="delete" type="submit" id="delete" value="Delete"></td> </tr> <?php if(isset($_REQUEST['delete'])) { for($i=0;$i<$totalRows_select_events;$i++) { $del_id = $checkbox[$i]; $sql_del = ("DELETE FROM events WHERE event_id='[$del_id]'"); $result = mysql_query($sql_del, $DB_HTF) or die(mysql_error()); } mysql_close($DB_HTF); } ?> </table> </form> </tr> </body> </html> Any Help would be appreciated Quote Link to comment https://forums.phpfreaks.com/topic/72872-solved-php-mysql-checkbox-delete/ Share on other sites More sharing options...
fenway Posted October 12, 2007 Share Posted October 12, 2007 What's with the squares in the delete query? Quote Link to comment https://forums.phpfreaks.com/topic/72872-solved-php-mysql-checkbox-delete/#findComment-367820 Share on other sites More sharing options...
jr_cumbo Posted October 15, 2007 Author Share Posted October 15, 2007 Yeah my mistake...Thanx Quote Link to comment https://forums.phpfreaks.com/topic/72872-solved-php-mysql-checkbox-delete/#findComment-370250 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.