PDA

View Full Version : drop down list (php) from sql db



pucca
October 12th, 2006, 06:03 AM
hi there

I've got a dropdown list where I get the values from a mysql db.

Here's my code for creating a rs which works fine..:


$sql = "Select * FROM desta_provinces where CountryId = 1 and Id != 9 and Id != 90 and Id != 98 ORDER BY Name asc";
$rsprovinces = mysql_query($sql,$conn);
$rows = mysql_fetch_assoc($rsprovinces);
In my list, everything displays correctly, but when I select one value, and click on the button of the form, It doesn't take my Id with. Heres my code:



<form action="provinces.php?Id=<?php echo $rows['Id'];?>" method="post">
<?PHP
if( mysql_num_rows($rsprovinces)>0 ) {
echo '<select name="provlist">';
while ( $rows = mysql_fetch_array ($rsprovinces) ) {
echo '<option>' . $rows['Name'] . '</option>';
}
echo '</select>';
}
?>

<input name="btn" type="submit" value="go" />

</form>
Everything seems fine to me? can somebody please help me?

thanks!

pucca
October 12th, 2006, 11:40 AM
Hi? Is there NOBODY that can help me????? pllleeaase?!?!

bwh2
October 12th, 2006, 11:53 AM
relax dude, you only posted 5 hours ago. you need to set a value for your option.


echo '<option value="'.$row['Id'].'">' . $rows['Name'] . '</option>';

pucca
October 12th, 2006, 02:46 PM
thanks man! I guess the time difference gets to me a bit. When you start working, my day is almost ending ... :-/

bwh2
October 12th, 2006, 02:49 PM
yeah, and during the school year a lot of people aren't online till around 4PM EST. such is life. glad to hear it worked.