Hi all, I have a 2 radio button . So i want to get the selected radio button value as it is stored in the data base . here's the code : echo"<tr> <td >Availability : </td> <td><label>Yes<input class=\"inputbox\" type =\"radio\" name=\"availability2\" size=\"40\" value=if($availability=='yes') echo 'checked=\"checked\"';</label></td> var_dump($availability); <td><label>No<input class=\"inputbox\" type =\"radio\" name=\"availability2\" size=\"40\" value=if($availability=='no') echo 'checked=\"checked\"';</label></td> </tr>"; Code (markup): the result of var_dump($availability) is var_dump(no) , i don't know were's the mistake !! thanks for reply
You cannot put IF inside echo. View the generated HTML-code. Also, you dont need to escape " quotes, when you do echo with single qoute '. echo"<tr> <td >Availability : </td> <td><label>Yes<input class=\"inputbox\" type =\"radio\" name=\"availability2\" size=\"40\" value="; if($availability=='yes') echo 'checked="checked"'; echo "</label></td> <td><label>No<input class=\"inputbox\" type =\"radio\" name=\"availability2\" size=\"40\" value="; if($availability=='no') echo 'checked="checked"'; echo "</label></td> </tr>"; Code (markup):