hey there, i have (what i think) is prolly a simple problem... ive searched and searched and havent been able to find anything about it that will work for me
i have an admin section that allows a user to add a record to a table called houses .... one of the fields in the houses table is called "city" and there are only certain cities that are allowed in this field, so i want the add_record form to only allow those cities to be entered...... thusly a dropdown selection is perfect...... what im trying to do is populate a dropdown box from another table (called latlong).... the dropdown box will be called city and be populated by the cityName column in the latlong table.... but something is working correctly, it seems that nothing is getting selected from the table
here is my code, you can ignore the first form as its a search form for another part of my admin section.... the first table part is just setting up the column headers, so you can ignore that as well.... the problem really begins at the echo("<select name=city>"); part
<?php
include("other.inc");
include("accesscontrol2.php");
echo "<h3>Admin Control</h3>";
echo "<form name='search' action='show_search_admin.php' method='post'>";
echo "Enter your search criteria:<br>";
echo "<input type='text' name='criteria'><br>";
echo "<input type='submit' name='search' value='Search'>";
echo "</form>";
$connection = mysql_connect($host,$user,$password)or die ("couldn’t connect to server");
$db = mysql_select_db($database,$connection)or die ("Couldn’t select database");
$query = "SELECT DISTINCT(cityName) FROM latlong";
$result = mysql_query($query) or die (mysql_error($connection));
echo "<form name='add' action='admin_add.php' method='post'>";
echo "Enter the information to be added to the database:<br>";
echo "<table cellpadding='5' border='1'>";
echo "<td valign='top' width='15%'><b>Name</b></td>
<td valign='top' width='15%'><b>Address</b></td>
<td valign='top' width='10%'><b>City</b></td>
<td valign='top' width='5%'><b>Province</b></td>
<td valign='top' width='8%'><b>Postal Code</b></td>
<td valign='top' width='10%'><b>Phone Number</b></td>
<td valign='top' width='10%'><b>Alt. Phone Number</b></td>
<td valign='top' width='20%'><b>Description</b></td>
<td valign='top' width='10%'><b>Grouping</b></td>";
echo "<tr>
<td valign='top' width='15%'><input type='text' name='add_name' size='15%'</td>
<td valign='top' width='15%'><input type='text' name='add_address' size='15%'</td>
<td valign='top' width='10%'><select name='add_city'>";
echo("<select name=city>");
while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
extract($row);
//$city = $row['cityName'];
echo "$cityName";
//echo("<option value=$city>$city</option>");
}
echo("</select> ");
echo "<td valign='top' width='5%'><input type='text' name='add_province' size='5%'</td>
<td valign='top' width='8%'><input type='text' name='add_postalCode' size='8%'</td>
<td valign='top' width='10%'><input type='text' name='add_phoneNum' size='10%'</td>
<td valign='top' width='10%'><input type='text' name='add_altPhoneNum' size='10%'</td>
<td valign='top' width='20%'><input type='text' name='add_description' size='20%'</td>
<td valign='top' width='10%'><input type='text' name='add_grouping' size='10%'</td>";
echo "</tr>";
echo "</table>";
echo "<input type='submit' name='add' value='Add Record'>";
echo "</form>";
?>
and here is the output when i echo my query:
SELECT DISTINCT(cityName) FROM latlong
so it looks like the query is working correctly but its not doing anything.... any help here would be greatly appreciated