hi there..
i almost got the same problem.
i have 3 drop down menus in my page.
i was able to populate the first drop down menu.
the 2nd and 3rd drop down menu was not successfully
populated.
Well you have only provided one query there so that would be why only one menu is working. Does your script look something like the following:
$con=mysql_connect("localhost","username","password");
if (!$con) die("Couldn't connect to MySQL");
mysql_select_db("databasename",$con) or die("Couldn't open admin: ".mysql_error());
$q1=mysql_query('SELECT table1.col1, table2.col2 FROM `table1`, `table2`');
echo '<select name="<fieldname>">';
while($rowa=mysql_fetch_array($q1))
{
echo '<option value="'.$rowa['<fieldname>'].'">';
echo $rowa['<fieldname>'].'</option>';
}
echo '</select>';
$q1=mysql_query('SELECT table1.col1, table2.col2 FROM `table1`, `table2`');
echo '<select name="<fieldname>">';
while($rowb=mysql_fetch_array($q1))
{
echo '<option value="'.$rowb['<fieldname>'].'">';
echo $rowb['<fieldname>'].'</option>';
}
echo '</select>';
$q1=mysql_query('SELECT table1.col1, table2.col2 FROM `table1`, `table2`');
echo '<select name="<fieldname>">';
while($rowc=mysql_fetch_array($q1))
{
echo '<option value="'.$rowc['<fieldname>'].'">';
echo $rowc['<fieldname>'].'</option>';
}
echo '</select>';
Note: In the above example replace <fieldname> with the real column name.
And also, just as an opinion, I find the examples in previous posts to be very basic and very non-php in a way. I believe the echo/print functions are the way to go.
Reputation Points: 410
Solved Threads: 258
Occupation: Genius
Offline 3,004 posts
since Sep 2007