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. Link to comment https://forums.phpfreaks.com/topic/179120-output-sql-using-html-label-tag/ 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> Link to comment https://forums.phpfreaks.com/topic/179120-output-sql-using-html-label-tag/#findComment-945053 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.