$sql="update wp_prli_links set url='?' where id = $id ";這樣不行就換種方式嘛,$url="?";
目前成都創(chuàng)新互聯(lián)已為千余家的企業(yè)提供了網(wǎng)站建設(shè)、域名、網(wǎng)絡(luò)空間、網(wǎng)站托管運營、企業(yè)網(wǎng)站設(shè)計、永寧網(wǎng)站維護等服務(wù),公司將堅持客戶導向、應用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。
$sql="update wp_prli_links set url='".$url."' where id = $id ";
取行的數(shù)據(jù)庫行的主鍵字段的值,然后對數(shù)據(jù)執(zhí)行更新操作:
update tabblename set xxx1 = 'aaaa',xxx2='bbbb' where id = 主鍵的值.
首先要用$_POST接收表單傳過來的數(shù)據(jù)然后用SQL寫到庫里update table set ........where id=\".$_REQUEST[id]
舉例如下:
創(chuàng)建userinfo_update.php頁面用于查詢用戶信息,先顯示信息,在修改:
先通過GET獲取用戶編號查詢用戶信息:
$sql = "select * from user_info where user_id='".$_GET['userId']."'";
$result = mysql_query($sql,$con);
if($row = mysql_fetch_array($result)){
}
頁面效果:
創(chuàng)建update.php文件,用于修改用戶信息:
使用到了mysql_affected_rows() 函數(shù)返回前一次 MySQL 操作所影響的記錄行數(shù)。
//通過post獲取頁面提交數(shù)據(jù)信息
$userId = $_POST[userId];
$userName = $_POST[userName];
$userAge = $_POST[userAge];
$sql = "update user_info set user_name='".$userName."',user_age=".$userAge." where user_id='".$userId."'";
mysql_query($sql,$conn);//執(zhí)行SQL
$mark? = mysql_affected_rows();//返回影響行數(shù)
$url = "userinf_select.php";
運行結(jié)果
創(chuàng)建delete.php文件,完成刪除用戶信息功能:
$userId = $_GET['userId'];
include 'connection.php';
$sql = "delete from user_info where user_id='".$userId."'";
mysql_query($sql,$con);
$mark? = mysql_affected_rows();//返回影響行數(shù)
if($mark0){
echo "刪除成功";
}else{
echo? "刪除失敗";
}
mysql_close($con);
運行結(jié)果:
網(wǎng)頁題目:php修改數(shù)據(jù)庫內(nèi)容表單 php修改sql語句
網(wǎng)頁路徑:http://bm7419.com/article38/dohgssp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供標簽優(yōu)化、網(wǎng)站導航、企業(yè)網(wǎng)站制作、網(wǎng)站內(nèi)鏈、靜態(tài)網(wǎng)站、定制網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)