Hey people π
I've searched the forums, but no joy
Basically the problem I have is deleting data from mysql.
I have this script on my delete.php -
<?php
$idtodelete = (int)$_POST['deleteID'];
if($idtodelete == 0)
{
print "Don't mess with me";
exit;
}
$db = "";
$dbconnection = mysql_connect("", "", "") or
die ('I canβt connect to the database.');
mysql_select_db($db,$dbconnection);
$query = "DELETE FROM table WHERE ID=$idtodelete";
$result = mysql_query($query);
if(mysql_affected_rows())
{
echo "Data is sucessfully deleted";
}
else
{
echo "Error Deleting record";
}
The script from button to delete record -
<head>
<script language="javascript">
function doDelete(delid)
{
if(confirm("Are you sure you want to delete the record " + delid))
{
var e = document.getElementById('deleteID');
document.theform.deleteID.value = delid;
document.theform.submit();
return true;
}
else
{
return false;
}
}
</script>
<body>
<a href="javascript:doDelete(<?php print $row['ID']; ?>);">Delete</a>
The problems are -
I don't want it to actually open another url in the window, I just want it to confirm, then delete / refresh (if posible)
The script isn't deleting, it's not even passing the ID to URL like - delete.php?ID=1
Thanks for even looking at the problem and thank you for any replies!