The data isn't being deleted from a table when user clicks on a button.
I have 2 buttons one of them to delete the data in mysql tabel which called data when I pressed the button. The data still in the table although other queries do work fine.
Here is my code:
<?php
$arr=array();
if(isset($_POST['add']))
{
$x=$_POST['x']."<br/>";
$y=$_POST['y']."<br/>";
$con = mysql_connect("localhost","root","");
if(!$con)
{
die('could not connect').mysql_errno();
}
else
{
mysql_select_db("kmean",$con);
$sql="INSERT INTO data (x, y)
VALUES
('$x','$y')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
$result = mysql_query("SELECT x,y FROM data");
while($row = mysql_fetch_array($result))
{
//echo $row['x'] . " " . $row['y']."<br/>";
array_push($arr,array($row['x'],$row['y']));
//print_r($r);
echo "<br />";
}
if(isset($_POST['delete']))
{
mysql_select_db("kmean", $con);
mysql_query("DELETE FROM data ");
}
}
//print_r($arr)."<br>";
mysql_close($con);