PHP/MySQL Database/Database Delete — различия между версиями

Материал из Web эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Версия 10:37, 26 мая 2010

Delete data from database by ID

<html>
<body>
<?php
$cnx = mysql_connect("mysql153.secureserver.net","wbex","password");
mysql_select_db("wbex");
$id = "1";
$ok1 = @mysql_query("DELETE FROM Employee WHERE ID="$id"");
if ($ok1) {
  echo("<p>Author deleted successfully!</p>");
} else {
  echo("<p>Error deleting author from database!<br />".
       "Error: " . mysql_error() . "</p>");
}
?>
</body>
</html>



Delete data from database table

<?php
   mysql_connect("mysql153.secureserver.net","wbex","password");
   mysql_select_db("wbex");
   $rowID = "001";
   $query = "DELETE FROM Employee WHERE ID="$rowID"";
   $result = mysql_query($query);
   if ((mysql_affected_rows() == 0) || mysql_affected_rows() == -1) {
        echo "<p>There was a problem deleting some of the selected items.</p>";
        exit;
   }
?>