Hi All,
I have a table called ALERTS that I want to hold data until the 'alert' is no more and then I want to dump it into the HISTORY table and delete it from ALERTS. This works fine except that when I check off an alert to be removed, it removes all of the alerts for this customer and puts it into HISTORY (obviously due to my INSERT statement). I want to be able to select just one alert at a time and have it written to HISTORY. The problem is when I use something like
mysql_query("INSERT INTO HISTORY SELECT * FROM ALERTS where alertid='$alertid' ");
it gives me a "query was empty" error.
Any help would be much appreciated.
Denise
The alerts.php page is this:
<?
$result = mysql_query("SELECT * FROM ALERTS WHERE custid='".$_GET['custid']."'")or die(mysql_error());
while($row=mysql_fetch_array($result) )
echo"
<form name='alerts' method='post' action='alerts_remove.php'>
<B>Customer Id:</B> $row[custid]
<B>Alertid:</B> $row[alertid]
<B>Date:</b>$row[date]
<b>Agent:</b>$row[agent]
<b>Memo:</b>$row[memo]
<input type='checkbox' value=".$row["alertid"]." name='delete_id[]'>
<input type='submit' value='remove'><BR><BR>
";
?>
And here is the alerts_remove.php page:
mysql_query("INSERT INTO HISTORY SELECT * FROM ALERTS");
$result = mysql_query($query) or die("error: " . mysql_error());
if (isset($_POST['delete_id']) && is_array($_POST['delete_id']))
{
$deleted = 0;
foreach ($_POST['delete_id'] as $alertid)
{
if (mysql_query("DELETE FROM ALERTS WHERE alertid='$alertid'"))
{
$deleted += mysql_affected_rows();
}
else
{
die("SQL error:<br />" . mysql_error());
}
}
}
echo"
Alert removed and copied to history.";
?>