I am trying to use the command foreach to create a drop down menu. That I can usually do, the problem is I am also adding some linking. Here is some my code:
<?sql
$sql2 = "SELECT mn.map, mn.route FROM maps m JOIN map_name mn ON (m.map_name = mn.map) WHERE `ship`='".$POST."'";
$result2 = mysql_query($sql2)
or die("Query Error".mysql_error());
while ($row = mysql_fetch_array($result2)) {
$mapname[$row] = $row;
}
?>
<form action="edit_map_which.php" method="post">
<table border=0 cellspacing=1>
<tr>
<td>
Map :
</td>
<td>
<SELECT name="map">
<option value="" SELECTED>Select a Map</option>
<?php
foreach( $mapname as $map => $route ){ **
?>
<option value="<?php echo $map ?>"><?php echo $route ?></option>
<?php }
?>
</SELECT>
</td>
</tr>
<tr>
<td>
<INPUT type="submit" name="Submit" value="Submit">
</td>
</tr>
</table>
** I get the error Invalid argument supplied for foreach() for this line.
I've tried quite a few different things for this, and I now feel like I am beating my head against the wall. Thanks for the help.