hya im trying to populate a drop down select list from the database i have set the database up and written the following out if anyone can help would be much appreicated
// Fetch user details
$userdata = mysql_query("select * from user where user_id = '".$_SESSION['userid']."' ");
$fetch_user = mysql_fetch_array($userdata);
$user_country = $fetch_user['user_country'];
$user_towns = $fetch_towns['user_towns'];
$userinfo = mysql_query("select * from user_info where user_id = '".$fetch_user['user_id']."' ");
$fetch_info = mysql_fetch_array($userinfo);
$fetch_towns = mysql_query("select * from towns where town_id = '".$fetch_towns['town_id']."' "); ITS THIS LINE TO QUERY
The following is the but to populate from
<?php
$towns = mysql_query("select * from towns where town_id = '".$user_town."' order by name asc");
?>
<select name="town" id="town" class="list_drop">
<option value="" selected="selected">Select</option>
<?php while($row = mysql_fetch_array($state)) { ?>
<option value="<?php echo $row['name']?>" <?php if($fetch_towns['town']==stripslashes($row['name'])) echo "selected";?> >
<?php echo $row['name']?>
</option>
<?php } ?>
</select>
Heres database table missing the inserted data
CREATE TABLE IF NOT EXISTS `towns` (
`town_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
`town` varchar(50) NOT NULL,
PRIMARY KEY (`town_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=993 ;