Hi all...
I'm trying to create a <select></select> field with data from a table.
It is a STATE table and the user needs to select the state and have the state NAME inserted into the user's table.
State table is setup like:
CREATE TABLE state (
state_id int(11) NOT NULL auto_increment,
country_id int(11) NOT NULL default '0',
name varchar(255) NOT NULL default '',
code varchar(10) default NULL,
PRIMARY KEY (state_id)
) TYPE=MyISAM AUTO_INCREMENT=85 ;
Query is setup like:
$user ="<select>
$query = 'SELECT * FROM state';
//Execute Query
$result = mysql_query($query);
$x = 0;
while ($x < mysql_num_rows($result)) :
$states = mysql_result($result, $x, 'name');
print "<option value='$name' ";
if (state==$states) print "selected";
print">$name</option>";
$x++;
endwhile;
print "</select>";
the select box shows up in the html...but none of the states from the DB are there....I'm stuck...please help..
Thank you