In this tutorial I go over deleting rows, not only in PHPMyAdmin, but in PHP as well. Once rows are deleted, they are not coming back. On the side note, it is good to use something that is unique to every row when modifying them or deleting them. Otherwise you can delete anything that matches the name being “orange” and delete two rows. This is why I usually always have an ID field in my rows.
Source used after the jump;
<?php
$link = mysql_connect('localhost', 'phpuser', 'phppass');
if (!$link) {
die('Not connected : ' . mysql_error());
}else{
//echo "I am connected. ";
}
// make foo the current db
$db_selected = mysql_select_db('test', $link);
if (!$db_selected) {
die ('Can\'t use test : ' . mysql_error());
}
if(isset($_REQUEST['del'])){
//DELETE FROM `test`.`tableish` WHERE `tableish`.`ID` = 3
$id = (int)$_REQUEST['del'];
$sql = "DELETE FROM `tableish` WHERE `ID` = $id";
mysql_query($sql);
}
$sql = "SELECT * FROM `tableish` ORDER BY `tableish`.`ID` ASC";
$result = mysql_query($sql, $link);
if(mysql_num_rows($result) > 0){
while($row = mysql_fetch_array($result)){
echo $row['name']."<a href=\"?del=".$row['ID']."\">Delete this row</a><br />\n";
}
}
?>