Tweet
The php code :
<?php
$connection=mysql_connect("localhost","root","")
or die("Couldn't connect to the server");
$db=mysql_select_db("produce",$connection)
or die ("Couldn't select database");
$result=mysql_query("DELETE FROM fruit WHERE name='CD'");
$result=mysql_query("SELECT * FROM fruit");
echo "<table border='1'>";
echo "<tr>";
echo "<th>Name</th><th>Number</th><th>Quantity</th>";
echo "</tr>";
while($row=mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>",$row['name'],"</td><td>",$row['number'],"
</td><td>",$row['quantity'],"</td>";
echo "</tr>";
}
echo "</table>";
mysql_close($connection);
?>
Before running the program :Name Number Quantity DVD 1 10 PENDRIVE 2 50 CD 3 25 KEYBOARD 4 15
After running the program :Name Number Quantity DVD 1 10 PENDRIVE 2 50 KEYBOARD 4 15
This post is about how to delete a record from mysql database using php.