nashsaint Posted October 26, 2009 Share Posted October 26, 2009 Hi, This is what I am trying to accomplish: [] Male [] Female Simple tick boxes populated from sql but i just don't know how to do it. I have the sql query and thinking of outputting it this way: <form> <label for="maleID">malefromsql</label> <input type="radio" name="sex" id="maleID" /> <br /> <label for="femaleID">femalefromsql</label> <input type="radio" name="sex" id="femaleID" /> </form> but i dont know how to pass the sql query result to a variable and finally output it . Any help is appreciated greatly. thanks. Quote Link to comment Share on other sites More sharing options...
cags Posted October 26, 2009 Share Posted October 26, 2009 Something like.. $result = mysql_query("SELECT gender FROM table"); $row = mysql_fetch_assoc($result); <form> <label for="maleID">malefromsql</label> <input type="radio" name="sex" id="maleID" <?php if($row['gender'] == 'Male') { echo 'selected="selected"'; } ?> /> <br /> <label for="femaleID">femalefromsql</label> <input type="radio" name="sex" id="femaleID" <?php if($row['gender'] == 'Female') { echo 'selected="selected"'; } ?> /> </form> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.