How to get radio button value from the data base

Discussion in 'PHP' started by peacemind, Jul 23, 2012.

  1. #1
    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
     
    peacemind, Jul 23, 2012 IP
  2. programming.russia

    programming.russia Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    1
    Trophy Points:
    0
    #2
    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):
     
    programming.russia, Jul 24, 2012 IP