我在存储和更新复选框值时遇到问题。
PHP代码
<?php
require ("****");
$id =$_REQUEST['id'];
$conn = mysql_connect('localhost', 'root', '');
mysql_select_db('registerforn');
$result = mysql_query("SELECT * FROM regi_user WHERE id = '$id'");
$row = mysql_fetch_array($result);
extract($_POST);
if(isset($save)){
$skills=implode("," , $skills);
$sql=mysql_query("UPDATE regi_user SET emp_name ='$emp_name',email ='$email',gender ='$gender',interest='$interest' , skills='$skills' WHERE id = '$id'");
$retval = mysql_query( $sql, $conn );
header('location:display.php');
}
?>
HTML代码
<tr><th>
Option Subject</th>
<th>
<?php
$chkbox=$row['skills'];
$skills=explode("," , $chkbox);
?>
<input <?php if(in_array("oops",$row)){echo "checked";}?> type="checkbox" class="myCheckBox" name="skills[]" id="skills" value="oops">OOPS<br> <!--class="myCheckBox"-->
<input <?php if(in_array("pic",$row)){echo "checked";}?> type="checkbox" class="myCheckBox" name="skills[]" id="skills" value="pic">Programin In C<br>
<input <?php if(in_array("java",$row)){echo "checked";}?> type="checkbox" class="myCheckBox" name="skills[]" id="skills" value ="java" >JAVA<br>
<input <?php if(in_array("ds",$row)){echo "checked";}?> type="checkbox" class="myCheckBox" name="skills[]" id="skills" value="ds">DS
<div id="msg55"></div>
<!--<div class="msg22"></div>class="myCheckBox"-->
</th>
</tr>
这是我的更新页面。所以那个时间发生了问题 错误页面