dropdown list doubt

Links for php scripts

Moderators: macek, egami, gesf

actuallypb
New php-forum User
New php-forum User
Posts: 1
Joined: Mon May 21, 2012 2:14 am

dropdown list doubt

Postby actuallypb » Mon May 21, 2012 3:12 am

I'm using following script to display dropdown list :

$SQL2 = "SELECT circle_name FROM circleinfo WHERE company_name= $sess";
$result2 = mysql_query($SQL2);
echo '<label>Select username:</label>';
echo '<select name="circlename">';
echo '<option value="">Select</option>';

while ($row = mysql_fetch_assoc($result2))
{
$va = $row['circle_name'];
echo "<option value='$va'>$va</option>";
}
echo '</select>';

now my doubt is, how do i retrieve selected value from dropdown list?? when I use $_POST['circlename']; I get an error. when I use if ($_SERVER['REQUEST_METHOD'] == 'POST') then dropdown list doesnt get displayed. please help. thank you.

User avatar
macek
php-forum Active User
php-forum Active User
Posts: 277
Joined: Wed Aug 25, 2010 10:42 am
Contact:

Re: dropdown list doubt

Postby macek » Mon May 21, 2012 10:48 am

Code: Select all

echo "<option value='$va'";
if(isset($_POST['circlename']) && $_POST['circlename'] == $va) echo ' selected="selected"';
echo ">$va</option>";


Return to “PHP Scripts”

Who is online

Users browsing this forum: No registered users and 1 guest