Modified: Similar to add, need to display default values
Embed PHP code query database First
$code $_get ["C"]; $db New Mysqli ("localhost", "root", "159357", "Renyuanxinxi"); $ainfo = "SELECT * from info where code= ' {$code} '"; $binfo $db->query ($ainfo); $cinfo $binfo->fetch_row ();
Display the queried values in the Web page (embed the appropriate short PHP code in the form to assign the settings)
<form action= "xiugaichuli.php" method= "POST" > <div><input type= "hidden" name= "code" value= "<?php Echo$ainfo[0];?> "/></div> <div> name: <input type=" text "name=" name "value=" <?php Echo$ainfo[1];?> "/></div> <div> Gender://true false to determine<input type= "Radio" name= "Sex" value= "1" <?phpEcho $ainfo[2]? " Checked= ' checked ' ":" "?>/>male <input type= "Radio" name= "Sex" value= "0" <?phpEcho $ainfo[2]? "": "checked= ' checked '"?>/>female</div> <div>Ethnicity:<select name= "Nation" > <?PHP$sql= "SELECT * From Nation"; $result=$db->query ($sql); $attr=$result-Fetch_all (); foreach($attr as $v)//Drop- down list set default { if($v[0]==$ainfo[3]) { Echo"<option selected= ' selected ' value= ' {$v[0]} ' >{$v[1]} </option> "; } Else { Echo"<option value= ' {$v[0]} ' >{$v[1]} </option> "; } } ?> </select> </div> <div> Birthdays: <input type= "text" name= "Birthday" value= "<?ph P Echo$ainfo[4];?> "/></div> <div><input type=" Submit "value=" Modify "/></div></form>
Create a modification processing page (value First, then modify the statement to select the column to be modified based on the primary key value, and then execute)
<?PHP$code=$_post["Code"];//Take value$name=$_post["Name"];$sex=$_post["Sex"];$nation=$_post["Nation"];$birthday=$_post["Birthday"];$db=NewMysqli ("localhost", "root", "159357", "Renyuanxinxi");$sql= "Update info set name= ' {$name} ', sex={$sex},nation= ' {$nation} ', birthday= ' {$birthday} ' where code= ' {$code}‘";//Select the column you want to modify with a modified statement based on the primary key value$db->query ($sql);//ExecutionHeader("location:main.php");
PHP Data Access (Modify)