I have a field in a MySQL database called 'location' - it serves up North, South, East, West only.
I have used this code to get only the 4 results that are distinct:
$query_form = "SELECT DISTINCT location FROM hotel ORDER BY location ASC";
$result_form = mysqli_query($dbc, $query_form) or die('die query error');
$row_form = mysql_fetch_array($result_form, MYSQLI_NUM);
I wanted to use the four results from this query to populate a table such that:
<option value='1'>North</option>
<option value='2'>South</option>
<option value='3'>East</option>
<option value='4'>West</option>
I have used this:
foreach ($row_form['location'] as $k => $v) {
echo '<option value="' . $k . '">' . $v . '</option>\n';
}
but I fear that my approach will not work - with regret, I am a noob and unable to work out what is wrong!
Thanks
mysql_fetch_assoc();
or change tomysql_fetch_array($result_form, MYSQL_ASSOC);
– kjy112 Feb 25 '11 at 16:53