Jump to content

Recommended Posts

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.

 

Link to comment
https://forums.phpfreaks.com/topic/165045-solved-fetch-result-into-select-box/
Share on other sites

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>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.