Hi,
I want to retrieve a key value for the option selected in the drop down box,and i also want to you to tell me how to use that key value

<select name="role" style="width: 145px">';
		$result=selecttbl("ugname","ugroup");
		while($nt=mysql_fetch_array($result))
		{
		print'<option>'.$nt[ugname].'';
                                print'</option>';
		}
		print'</select></td>

Recommended Answers

All 6 Replies

print'<option value="{$nt[ugname]}">'.$nt[ugname].'';
print'</option>';

If you have any key column other than ugname then you can use that as value.

Hi,
I want to retrieve a key value for the option selected in the drop down box,and i also want to you to tell me how to use that key value

<select name="role" style="width: 145px">';
$result=selecttbl("ugname","ugroup");
while($nt=mysql_fetch_array($result))
{
print'<option>'.$nt[ugname].'';
print'</option>';
}
print'</select></td>

<p><select" name="optcountry" class="">
<option value="" selected></option>
<?php  
   //GET ALL THE COUNTRIES IN DATABASE

       [your connection and query to database here]

	while ($row = mysql_fetch_assoc($results)) {
	$countries = $row['countries_name'];
    echo "<option value=\"$countries\">$countries</option>";
} 
	?>
  </select></p>

to use that...click the value inside your form.
call the $_POST['optcountry'] this will return the value.

Hi,
I want to retieve option value for the corresponding name in the drop down box,please help me out,i tried in the below method,but it doesn't go well.

<select name="role" style="width: 145px">';
$result=selecttbl("ugname","ugid","ugroup");
while($nt= mysql_fetch_assoc($result))
{
print'<option value="'.$nt[ugid].'">'.$nt[ugname].'';
print'</option>';
}
 print'</select>
commented: Creating duplicate threads wouldn't help you in any way. -2

I think you problem is that you don't have quotes around the $nt array indexes. This should fix your problem:

print'<option value="'.$nt['ugid'].'">'.$nt['ugname'].'';

Hi,
I din't got the value please help me out

Hi,
I din't got the value please help me out

print'<option>'.{$nt{'ugname'}}.'';

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.