我有回复后保留值的代码。我还想使用GET保留该值。例如我有(example.php?id)我想使用$ _GET [' id']我应该采用什么方法保留价值。
if(isset($_POST) && isset($_POST['sym1']) && in_array($condition1,$_POST['sym1']))
$strIsChecked='checked="checked"';
else
$strIsChecked=null;
echo '<br><input type="checkbox" '.$strIsChecked.' title ="'.$otherspec1.'" name="sym1[]" onclick="javascript: submit()" value ="'.$condition1.'">'; echo ''.$condition1.'</td>';
答案 0 :(得分:0)
这是你需要的吗?
// this is suppose to replace your If(...)..
$sym1 = isset($_REQUEST["sym1"]) ? $_REQUEST["sym1"] : '';
$strIsChecked = in_array($sym1, array('option1', 'option2')) ? 'checked="checked"' : null;
echo '<br><input type="checkbox" '.$strIsChecked.' title ="'.$otherspec1.'" name="sym1[]" onclick="javascript: submit()" value ="'.$condition1.'">';
echo ''.$condition1.'</td>';
// your code with modification .....
if(isset($_REQUEST) && isset($_REQUEST['sym1']) && in_array($condition1,$_POST['sym1']))
$strIsChecked='checked="checked"';
else
$strIsChecked=null;
echo '<br><input type="checkbox" '.$strIsChecked.' title ="'.$otherspec1.'" name="sym1[]" onclick="javascript: submit()" value ="'.$condition1.'">'; echo ''.$condition1.'</td>';