populating dropdown list problems

From: Date: Mon, 09 Apr 2001 19:07:59 +0000
Subject: populating dropdown list problems
Groups: php.general 
Request: Send a blank email to php-general+get-47856@lists.php.net to get a copy of this message
I would like to populate a dropdown list from a particular field of a bunch of records. Here's what I have so far on the modify page but it doesn't list stuff from the database, all it prints is the number 1 which isn't in any of the records. One version of this will be on an add page and another will be on a modify page which has the current field selected. For the add script, I'd just lose all the selected stuff that's on there now. print "<select name=\"owner\">"; $result = mysql_query("SELECT owner,agent FROM homes;"); while($a_row = mysql_fetch_array($result)) { printf('<option name="owner" value="'.$a_row[owner].'">'.$a_row[owner].'</option>', $a_row[owner], ($owner == $a_row[owner]) ? "selected" : "", $a_row[owner]); } print "</select>"; What am I doing wrong in this code? Even when I take out the selected stuff, I still get a value of 1 in the list instead of the actual contents of the field. Any help is greatly appreciated! __________________ Jason Dulberg Extreme MTB http://extreme.nas.net

« previous php.general (#47856) next »