Instead of:
> $row = mysql_fetch_array($sql)

$row = mysql_fetch_assoc($sql)

Humberto Silva
World Editing

-----Original Message-----
From: John W. Holmes [mailto:[EMAIL PROTECTED] 
Sent: sexta-feira, 23 de Janeiro de 2004 15:42
Subject: Re: [PHP-DB] Drop down box NOT populated


> Jsut a guess...
> Your row has a capital 'A' in the SQL statement, and a lower case 'a' 
> in teh $row[] call..
> does that matter?

Yep, that would matter, but not the exact problem. I don't know if this
thread has already been answered or not, so...

The real problem is with this:

> $sql = mysql_query("SELECT distinct(Account) FROM Backlog")or die 
> ("Something bad happened here: " . mysql_error()) ;
> echo "<select name=\"account\">\n";
> echo "<option>\n";
> while ($row = mysql_fetch_array($sql))
>   {
>       echo ' <option 
> value="'.$row["account"].'">'.$row["account"]."</option>\n";

because there is no "account" index in $row. You're not selecting
"account", you're selecting "distinct(Account)".

So, you could do it the hard way and use $row['distinct(Account)'] as
your value or change your SQL to:

$sql = mysql_query("SELECT distinct(Account) AS acc FROM Backlog")or die

and use $row['acc']. This is called making an alias. You alias the
distinct(account) column to be called "acc". You can name the alias what
ever you want.

If you developed with your error_reporting() set to E_ALL, you'd have
gotten a notice about "Undefined index 'account' in $row" that may have
tipped you off to all of this.

Hope this helps.

---John Holmes...

PHP Database Mailing List (
To unsubscribe, visit:

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to