Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/72872-solved-php-mysql-checkbox-delete/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.