当我在数据库中提交选中的复选框时,我想保留选中的复选框..请帮我在这里做什么..这只是我的片段..
<?php
if (isset($_POST['submit'])) {
$radha = $_POST['radha'];
$radha_values = '';
foreach ($radha as $val) {
$radha_values .= $val . ",";
}
$sql = "INSERT INTO tbl_check (names) VALUES ('$radha_values')";
$res = mysql_query($sql) or die("error:" . mysql_error());
if ($res) {
echo "added";
}
mysql_close();
}
$sql = "select names from tbl_check where id=2";
$res = mysql_query($sql) or die("error:" . mysql_error());
$row = mysql_fetch_array($res);
$names = $row['names'];
echo $names;
?>
<form method="post" action="checkbox.php">
<input name="radha[]" type="checkbox" value="krishna"/> krishna
<input name="radha[]" type="checkbox" value="gopala"/>gopala
<input name="radha[]" type="checkbox" value="govinda"/>govinda
<input name="radha[]" type="checkbox" value="haribol"/>haribol<br/>
<input name="submit" type="submit" value="add"/>
</form>