wwhday
2017-02-03 14:58
location 跳转以后显示的条数是未添加的条数得刷新才能显示,这个是什么问题~~~求助
<?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('添加成功,网站的第{$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; } ?>
不明白你说的意思,给你看下我的
Duang~MySQLi扩展库来袭
28643 学习 · 181 问题
相似问题