Jump to content

[SOLVED] fetch result into select box


deepson2

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.