Error message

Notice: Undefined offset: 1 in counter_get_browser() (line 70 of /volume1/librarythings/www/sites/all/modules/counter/counter.lib.inc).

PHP + MySQL 資料刪除

Categories : 

使用PHP+MySQL,要從資料庫中將某筆資料刪除

其實,不太困難!

 

撈取資料的語法如下:

include("./Connections/link.php");
$query_Recordset1 = "SELECT * FROM table WHERE `status` ='show' ORDER BY `id` DESC";
$Recordset1 = mysql_query($query_Recordset1, $link) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

 

若是要刪除時,只需簡單的把select改成delete就可以囉!

我是使用在上一頁將要刪除的參數一起跟隨著網址送出,所以這邊是用GET的方式!

include("./Connections/list.php");
$query_Recordset1 = "Delete FROM table WHERE `id` ='$_GET[id]' ";
$Recordset1 = mysql_query($query_Recordset1, $link) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

沒有想像中那麼的困難吧~

如果大家有需要的話,也可以參考一下囉!

Read more about: