I had design a form and value of form are showing in table format.In table i have two columns which are buttons Edit and Delete respectively.I want to perform update and delete query on that buttons where id is first column in my table. here is code
<?php
mysql_connect("localhost","root","")or die("Unable to create to connection");
mysql_select_db("sunil") or die(mysql_error());
if(isset($_REQUEST['submit']))
{
$Id= $_POST["id"];
$Name1=$_POST["t1"];
$Name2=$_POST["t2"];
$Sex=$_POST["sex"];
$Country=$_POST["Country"];
$Hobby=$_POST["check"];
$Email=$_POST["t3"];
$Pass=$_POST["p1"];
$Repass=$_POST["p2"];
$sql="INSERT INTO registration (Your_id,First_Name,Last_Name,Sex,Country,Hobbies,Email,Password,Repassword) VALUES('$Id','$Name1','$Name2','$Sex','$Country','$Hobby','$Email','$Pass','$Repass')";
mysql_query($sql);
}
$result = mysql_query("SELECT * FROM registration");
print "<table border=1>";
while($row = mysql_fetch_array($result))
{
print "<tr>";
print "<td>".$row['Your_id']."</td>";
print "<td>".$row['First_Name']."</td>";
print "<td>".$row['Last_Name']."</td>";
print "<td>".$row['Sex']."</td>";
print "<td>".$row['Country']."</td>";
print "<td>".$row['Hobbies']."</td>";
print "<td>".$row['Email']."</td>";
echo '<td><input type="submit" value="Edit" onclick="return update()"></td>';
// tell me code of update()
echo '<td><input type="submit" value="Delete" onclick="DELETE FROM registration WHERE Your_id=id"></td>';
// tell me what to use in place of is in this line
print "</tr>";
}
print "</table>";
?>
And here is snap shot