Click to See Complete Forum and Search --> : About get value from drop down box


dummyagain
January 8th, 2008, 01:10 PM
I would like to use php to get the vaue from the drop down box.
My case is that when the user choose a group from a drop down box, it will load the name list from the group.

Here is my code

$result = mysql_query("SELECT name FROM invitelist where group = " . group2)
// group2 is the value from the drop down box in the same form and i am //not sure if this line is correct
or die(mysql_error());


while($row = mysql_fetch_array( $result )) {
echo "<option value=\"$row['name']>\"" . $row['name'] . "</option>";
}



however, i get an error of Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/a6870809/public_html/index.php on line 43

Thanks

PeejAvery
January 8th, 2008, 01:33 PM
Change...
echo "<option value=\"$row['name']>\"" . $row['name'] . "</option>";
To...

echo "<option value=\"" . $row['name'] . ">\"" . $row['name'] . "</option>";

dummyagain
January 8th, 2008, 02:23 PM
Thanks.

But I still cannot pass the value from the drop down box (<select name=""> <option value ="">a</option>...) to the server side to load the group list...

how i can do so?

thanks

PeejAvery
January 8th, 2008, 02:33 PM
To pass the value of the <select> tag to the server you either have to use it in a form with a method set to GET or POST. Or use AJAX. Which are you attempting?