PHP SQL Delete Query
The delete query is used to delete entries from the database. The below example shows how this is done.
$dbuser="username"; $dbpass="password"; $dbname="mydata"; //the name of the database $chandle = mysql_connect("localhost", $dbuser, $dbpass) or die("Connection Failure to Database"); mysql_select_db($dbname, $chandle) or die ($dbname . " Database not found. " . $dbuser); $mainsection="links"; //The name of the table where web links are stored $idno=10; $query1="delete from " . $mainsection . " where id = " . $idno; mysql_db_query($dbname, $query1) or die("Failed Query of " . $query1); echo "Link with ID " . $idno . " has been deleted as requested.<br>"; }
The delete item is chosen by inique id number, "$idno", which in this case is set to 10. The table the entry is deleted form is the "links" table which is where internet links are stored.