課程
/后端開發(fā)
/PHP
/Duang~MySQLi擴(kuò)展庫來襲
location 跳轉(zhuǎn)以后顯示的條數(shù)是未添加的條數(shù)得刷新才能顯示,這個(gè)是什么問題~~~求助
2017-02-03
源自:Duang~MySQLi擴(kuò)展庫來襲 2-7
正在回答
<?php header('content-type:text/html;charset=utf-8'); error_reporting(E_ALL^E_NOTICE); $mysqli?=?new?mysqli('localhost','root','199486','test'); if($mysqli->connect_errno){ ????die('connect?error'.$mysqli->connect_error); } $mysqli->set_charset('utf8'); $username?=?$_POST['username']; $password?=?$_POST['password']; $age?=?$_POST['age']; $act?=?$_GET['act']; $id?=?$_GET['id']; switch?($act){ ????case?'addUser': ????????$sql?=?"INSERT?student(username,password,age)VALUES ????????('{$username}','{$password}','{$age}')"; ????????$res=$mysqli->query($sql); ????????if($res){ ????????????$insert_id?=?$mysqli->insert_id; ????????????echo?"<script> ????????????????????alert('添加成功,網(wǎng)站的第{$insert_id}'); ????????????????????location.href='user_list.php'; ????????????</script>"; ????????????exit; ????????}else{ ????????????echo?"<script> ????????????????????alert('添加失敗'); ????????????????????location.href='addUser.php'; ????????????</script>"; ????????} ????????break; ????case?'delUser': ????????$sql?=?"DELETE?FROM?student?WHERE?id=".$id; ????????$res?=?$mysqli->query($sql); ????????if($res){ ????????????$mes?=?"刪除成功"; ????????}else{ ????????????$mes?=?"刪除失敗"; ????????} ????????$url?=?"user_list.php"; ????????echo?"<script> ????????????????????alert('{$mes}'); ????????????????????location.href='{$url}'; ????????????</script>"; ????????break; } ?>
不明白你說的意思,給你看下我的
wwhday 提問者
西蘭花偉大炮 回復(fù) wwhday 提問者
舉報(bào)
本教程從面向?qū)ο蠛兔嫦蜻^程兩個(gè)方面為你開啟MySQLi學(xué)習(xí)之旅
1 回答查詢語句加條件and后面的密碼查詢不到
3 回答老師,addUser.php:數(shù)據(jù)“添加失敗,重新添加”是什么原因?
6 回答請(qǐng)問各位大神,addUser.php"添加數(shù)據(jù)失敗,請(qǐng)重新添加”是什么原因?
5 回答老師,請(qǐng)問我在添加用戶名為中文字符時(shí),數(shù)據(jù)庫中保存的記錄都顯示為問號(hào)???
1 回答插入中文,無法添加,英文可以添加
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2017-02-13
不明白你說的意思,給你看下我的