i have the codes that retain the value after post back. i also want to retain the value using GET. example i have ( example.php?id) i want to retain the value using $_GET['id'] what method should i do .
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>';
Is this what you need?
// 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>';