PHP+ajax 無重新整理刪除資料_PHP教程

來源:互聯網
上載者:User
首先本例基於留言本整理版修改。
我們使用了jquery.js來實現ajax和dom刪除
首先加入
複製代碼 代碼如下:


給table加個
複製代碼 代碼如下:
id="t"

寫個js:
複製代碼 代碼如下:


刪除連結改成 href="javascript:delItem('')"
delete.php的修改就是把錯誤語句改成直接輸出就行了。
OK完成。
index.tpl :
複製代碼 代碼如下:




所有留言





Welcome:
退出

登入
註冊

發表留言











[] 發表於:




附件:">

">修改 ')">刪除







delete.php :
複製代碼 代碼如下:
require('common.php');
// 查詢出留言資訊
$q = $query->query('select * from gb_content where id='.intval($_GET['id']));
$rs = $query->fetch_array($q);
$error = array();
if ($rs['user_id']!=intval($_SESSION['user_id'])) {// 判斷user_id是否相同
$error = '該資訊你不能刪除,只能刪除自己發布的';
}
if (!$error) {
$query->query('delete from gb_content where id='.intval($_GET['id']));//刪除語句
if ($rs['user_file']) {//刪除附件
@unlink('uploads/'.$rs['user_file']);
}
echo 1;//表示成功
} else {
echo $error;
}
?>

http://www.bkjia.com/PHPjc/321249.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/321249.htmlTechArticle首先本例基於留言本整理版修改。 我們使用了jquery.js來實現ajax和dom刪除 首先加入 複製代碼 代碼如下: script type="text/javascript" src="lib/jquery...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.