hey there, im trying to make a form that allows a user to add a address.... only certain cities are available and they are provided in a dropdown box on the form
once the user adds the record, it gets passed to the add_admin.php file, which then takes the city name from the form and matches it up with a table, called latlong, that contains all the city names and their corresponding latitude and longitude.... these values for latitude and longitude are then added to the info the user typed in and the new record is then finally added to the table
i dont have a problem adding a new record without doing the latlong table search, when i try to find the corresponding latitude or longitude in the latlong table im getting underfined index errors
here is my code:
<?php
include("other.inc");
include("accesscontrol2.php");
echo "<h3>Admin Control</h3>";
$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");
echo "<table cellpadding='1' 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='10%'>{$_POST['add_name']}</td>
<td valign='top' width='15%'>{$_POST['add_address']}</td>
<td valign='top' width='10%'>{$_POST['add_city']}</td>
<td valign='top' width='5%'>{$_POST['add_province']}</td>
<td valign='top' width='8%'>{$_POST['add_postalCode']}</td>
<td valign='top' width='10%'>{$_POST['add_phoneNum']}</td>
<td valign='top' width='10%'>{$_POST['add_altPhoneNum']}</td>
<td valign='top' width='20%'>{$_POST['add_description']}</td>
<td valign='top' width='10%'>{$_POST['add_grouping']}</td></tr>";
echo "</table>";
$find_lat="select * from latlong where cityName =\"{$_POST['add_city']}\"";
$result_lat = mysql_query($find_lat) or die (mysql_error($connection));
while($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
extract($row);
//$temp_lat='$latitude'; this is the part that is not working, i need to make a copy of the lat
//$temp_long='$longitude'; and long values that correspond to the matching cityName
// from the latlong table, then copy these values into my insert function
}
$add_record = "insert into houses (name, address, city, province, postalCode, phoneNum,
altPhoneNum, description, grouping, latitude, longitude) values (\"{$_POST['add_name']}\",
\"{$_POST['add_address']}\", \"{$_POST['add_city']}\", \"{$_POST['add_province']}\",
\"{$_POST['add_postalCode']}\", \"{$_POST['add_phoneNum']}\", \"{$_POST['add_altPhoneNum']}\",
\"{$_POST['add_description']}\", \"{$_POST['add_grouping']}\", '$temp_lat', '$temp_long')";
$result_add = mysql_query($add_record) or die (mysql_error($connection));
echo "The above record was added.";
?>
as you can see in my comments in the code, i need to be able to copy the data from the latlong table and add it to the record about to be added to the houses table..... can anybody help me here, i think its a small thing, but i no matter what i do it wont work... thx in advance