首页 > 代码库 > php-> msql 修改
php-> msql 修改
修改 <?php $code = $_GET["c"]; //造连接对象 $db = new MySQLi("localhost","root","123","mydb"); //写SQL语句 $sinfo = "select * from info where code=‘{$code}‘"; $rinfo = $db->query($sinfo); $ainfo = $rinfo->fetch_row(); ?> <form action="xiugaichuli.php" method="post"> <div><input type="hidden" name="code" value=http://www.mamicode.com/"<?php echo $ainfo[0]; ?>" /></div> <div>姓名:<input type="text" name="name" value=http://www.mamicode.com/"<?php echo $ainfo[1]; ?>" /></div> <div>性别: <input type="radio" name="sex" value=http://www.mamicode.com/"1" <?php echo $ainfo[2]?"checked=‘checked‘":"" ?> />男 <input type="radio" name="sex" value=http://www.mamicode.com/"0" <?php echo $ainfo[2]?"":"checked=‘checked‘" ?> />女 </div> <div>民族: <select name="nation"> <?php $sql = "select * from nation"; $result = $db->query($sql); $attr = $result->fetch_all(); foreach($attr as $v) { if($v[0]==$ainfo[3]) { echo "<option selected=‘selected‘ value=http://www.mamicode.com/‘{$v[0]}‘>{$v[1]}"; } else { echo "<option value=http://www.mamicode.com/‘{$v[0]}‘>{$v[1]}"; } } ?> </select> </div> <div>生日:<input type="text" name="birthday" value=http://www.mamicode.com/"<?php echo $ainfo[4]; ?>" /></div> <div><input type="submit" value=http://www.mamicode.com/"修改" /></div> </form> 修改处理
<?php $code = $_POST["code"]; $name = $_POST["name"]; $sex = $_POST["sex"]; $nation = $_POST["nation"]; $birthday = $_POST["birthday"]; //造连接对象 $db = new MySQLi("localhost","root","123","mydb"); $sql = "update info set name=‘{$name}‘,sex={$sex},nation=‘{$nation}‘,birthday=‘{$birthday}‘ where code=‘{$code}‘"; $db->query($sql); header("location:main.php");
php-> msql 修改
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。