deepson2 Posted July 7, 2009 Share Posted July 7, 2009 Hello, I want to show my result in to a select box. but i am just not able to get it into that. here is my code: <div class="commentRow"> <b>Add This blog to your Group: </b><select name="category1" onchange="enableothers(this.value);"> <option value="Select">Select a Category</option><?php echo "SELECT groupname FROM group where groupowner='$userid'"; //userid=7932 $cat = mysql_query("SELECT groupname FROM group where groupowner='$userid'"); if(mysql_num_rows($cat) > 0){ while($row1 = $op->select($cat)){ $group = $row1['groupname']; foreach($group as $value){ echo "<option value='$value'>$value</option>"; } } } ?> <option value="Others">Others</option> </select> </div> Can anyone tell me how can i get my result into select box? here i have two row with respective this id. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/165045-solved-fetch-result-into-select-box/ Share on other sites More sharing options...
deepson2 Posted July 7, 2009 Author Share Posted July 7, 2009 solved it. here is my code.may this ll help someone. <select name="select"> <option value="">--- Select ---</option> <?php // Get records from database (table "master1"). $list=mysql_query("select`groupname` from`group` WHERE groupowner = '$userid' order by id asc"); // Show records by while loop. while($row_list=mysql_fetch_assoc($list)){ ?> <option value="<?php echo $row_list['groupname']; ?>" <?php if($row_list['groupname']==$select){ echo "selected"; } ?>><?php echo $row_list['groupname']; ?></option> <?php // End while loop. } mysql_free_result($list); ?> </select> Quote Link to comment https://forums.phpfreaks.com/topic/165045-solved-fetch-result-into-select-box/#findComment-870326 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.