I’m really an amateur at this, but it seems to me like this code should work. The overall PHP function is called by a link and it’s meant to delete items. I really would like to give my users a fail-safe if they mistakenly click the button for the function. Any idea how to improve on this code and make it work?? (At the present time, it runs the delete statements regardless of the answer you provide at the confirmation.)
Thanks!
[CODE]function delete_item($itm_no)
{
echo ‘<SCRIPT language=”JavaScript”>
var answer = confirm(“Do you really want to delete this item?”)
if (answer)
{‘;
$sql2 = ‘DELETE FROM `Item` WHERE `item_id` = ‘. $itm_no .’ LIMIT 1′;
$sql3 = ‘DELETE FROM `List_Xref` WHERE `item_id` = ‘. $itm_no .’ LIMIT 1′;
$result2 = mysql_query($sql2)
or die (“Could not execute query: “.mysql_error());
$result3 = mysql_query($sql3)
or die (“Could not execute query: “.mysql_error());
echo ‘}else{}</SCRIPT>’;
}