假设我的代码 php 如下:
<?php
include("connectdb.php");
$check1 = "";
$check2 = "";
$check3 = "";
$check4 = "";
$check5 = "";
$query = "SELECT * FROM tblworkfaire";
$res = mysql_query($query) or die(mysql_error());
if($res){
while($data = mysql_fetch_array($res)){
if($data['1.DesTechnique'] == 1){
$check1 = "CHECKED";
echo $check1;
}
else if($data['1.DesTechnique'] == 2){
$check2 = " CHECKED";
}
else if($data['1.DesTechnique'] == 3){
$check3 = "CHECKED";
}
else if($data['1.DesTechnique'] == 4){
$check4 = "CHECKED";
}
else if($data['1.DesTechnique'] == 5){
$check5 = "CHECKED";
}
}
}
else{
echo "Fail";
}
?>
和HTML代码:
<form action="word2html.php" method="post">
<input type="radio" name="number1" value="1" checked="<? $check1; ?>">
</b><b>
<input name="number1" type="radio" value="2" checked="<? $check2; ?>">
</b><b>
<input name="number1" type="radio" value="3" checked="<? $check3; ?>">
</b><b>
<input name="number1" type="radio" value="4" checked="<? $check4; ?>">
</b><b>
<input name="number1" type="radio" value="5" checked="<? $check5; ?>">
</b>
我需要的:
我已将单选框值存储在数据库中,如果我从数据库中选择值等于 1,它将检查值等于 1 的单选框。
问题:
我只能从数据库中选择单选框的值,它不起作用。我该如何解决这个问题?请任何人帮助我,谢谢。