Re: drop down list not populating

From: Date: Wed, 28 Jan 2004 19:39:58 +0000
Subject: Re: drop down list not populating
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-175971@lists.php.net to get a copy of this message
Montagna, Dan wrote:
I've got the code for a drop down list and the drop down box displays--but with no info in it. The underlying table is populated so I could use some advice on what might be wrong from here.... <SELECT>
      <?
include("includes/db.php"); MYSQL_CONNECT(HOST,USER,PASS) OR DIE("Unable to connect to database"); @mysql_select_db(DB) or die( "Unable to select database"); $query=("select * from community order by community"); $result=mysql_query($query) or die ("Unable to Make the Query:" . mysql_error() ); while($row=mysql_fetch_array($result)){
Try a print_r($row) here to see what's being retrieved from the result set.
echo "<OPTION VALUE=".$row['community']."</OPTION>"; } ?> </SELECT> Any ideas?
If you view the HTML source of the page, do you see a bunch of empty <option> elements? If so, then $row['community'] isn't valid. Maybe it's a case issue and you should be using $row['Community']? Can't tell because you're using "SELECT *", though... -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com

« previous php.general (#175971) next »