Reputation: 59
so here is my code for deleting records in the database
<?php
error_reporting(0);
header("location:display.php");
$con=mysql_connect("localhost","root","");
mysql_select_db("bfp6",$con);
$result=mysql_query("DELETE FROM station WHERE id<>234");
$row=mysql_fetch_array($result);
mysql_close($con);
?>
What code should i add in order for it to display a warning that says "all records will be deleted, continue?" Then there is a yes and cancel options. when i click yes it will delete everything except for the one with id=234 and when i click cancel it will not do anything.I really don't have idea with this or even if it is possible. please help me out guys.
Upvotes: 0
Views: 865
Reputation: 193311
This is a job for a client side javascript. You can use native confirm dialog in this way:
<a href="delete.php" onclick="return confirm('All records will be deleted, continue?')">Delete records</a>
Once you click "Yes" browser will navigate to your script deleting records.
Upvotes: 3