To delete the record from the table, the user will need to enter the value in the textbox in HTML Design form...
delete.html
<html>
<head>
</head>
<body>
<form action=delete.php method=POST>
Enter no<input type=text name=n>
<input type=submit value=DELETE>
</form>
</body>
</html>
After inputting the value, it will be necessary to check if the value exists or not. If record does not exists then you have to display the appropriate message like "Record not found" or if record exists then that record will be deleted.....
delete.php
<?php
$no=$_POST['n'];
$cn=mysql_connect("localhost","root") or die(mysql_error());
$db=mysql_select_db("sybca",$cn) or die(mysql_error());
$row=mysql_query("select * from student where no=$no",$cn) or die(mysql_error());
$n=mysql_num_rows($row);
if($n<=0)
{
echo "Record not found";
exit;
}
else
{
mysql_query("delete from student where no=$no");
echo "Record Deleted";
}
?>
delete.html
<html>
<head>
</head>
<body>
<form action=delete.php method=POST>
Enter no<input type=text name=n>
<input type=submit value=DELETE>
</form>
</body>
</html>
After inputting the value, it will be necessary to check if the value exists or not. If record does not exists then you have to display the appropriate message like "Record not found" or if record exists then that record will be deleted.....
delete.php
<?php
$no=$_POST['n'];
$cn=mysql_connect("localhost","root") or die(mysql_error());
$db=mysql_select_db("sybca",$cn) or die(mysql_error());
$row=mysql_query("select * from student where no=$no",$cn) or die(mysql_error());
$n=mysql_num_rows($row);
if($n<=0)
{
echo "Record not found";
exit;
}
else
{
mysql_query("delete from student where no=$no");
echo "Record Deleted";
}
?>
No comments:
Post a Comment