php刪除一條記錄(刪除確認(rèn)提示)
來源:程序員人生 發(fā)布時間:2014-03-06 09:11:48 閱讀次數(shù):2493次
刪除記錄是php與數(shù)據(jù)庫常見的基本操作,下面我們主要是介紹php mysql刪除數(shù)據(jù)庫中的一條記錄方法.代碼如下:
echo '<a href="www.phpfensi.com/11.php?id=你要刪除記錄"onclick="return confirm("是否真的要刪除當(dāng)前記錄?")">刪除</a>'.
當(dāng)然你也可以利用下面方法實(shí)例刪除,代碼如下:
- <script language='javascript'>
- function del(id){
- if (false === confirm('是否真的要刪除當(dāng)前記錄?') )return;
- location.href = 'delete.php?id=' + id;
- }
- </script>
這里只要修改你的數(shù)據(jù)庫連接用戶名密碼,與數(shù)據(jù)庫名稱以及數(shù)據(jù)表名就可以了.
- <?php
- $conn = mysql_connect("localhost","root","8588027");
- mysql_select_db("test");
- $exec="delete from content where id='{$_get['id']}'";
- mysql_query($exec);
- mysql_close();
- echo "<script language='javascript'>location.href='code.php';</script>";
- ?>
生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈