I am attempting to create this dealer locator. The database and tables are all setup ok. I need some help with my code. I was hoping to get a few suggestions. I know what I want it to do. I would just like to learn and get this baby going.
Locator.php
<HTML>
<?php
$db = mysql_connect("localhost", "myuser", "mypassword");
mysql_select_db("mydatabase" ,$db) or die('Error connecting to database');
//here I am getting the zip code the user typed in and selecting the longitude and latitude off of that same row
$Getzip = mysql_query("SELECT smithslo, smithsla, smithszi FROM zdat1 WHERE ('$formzip' = smithszi)",$db) or die('Error, could not find Zip Code.');
[color=blue]
//My problem is somewhere in this area
//here i am trying to get the area of which i want to extract from my zip code table
$Maxlon = (smithslo + ".6000");
$Minlon = (smithslo - ".6000");
$Maxlat = (smithsla + ".6000");
$Minlat = (smithsla - ".6000");
//here i am trying to select the rows that are in that range, also it is spitting the error back at me that is on the line below.
$Getziprange = mysql_query("SELECT smithszi FROM '$Getzip' WHERE (smithslo BETWEEN '$Maxlon' AND '$Minlon') AND (smithsla BETWEEN '$Maxlat' AND '$Minlat')",$db) or die('Error, could not find Zip Codes within range.'); [/color]
//here i am trying to select the rows that have the same zip codes as the ones i selected
$Getdealer = mysql_query("SELECT Dealer, Address, City, State, Zip, Phone FROM learndb WHERE ('$Getziprange' = Zip)",$db) or die('Error retrieving dealers!');
if ($Shin)
{
mysql_query("SELECT Dealer, Address, City, State, Zip, Phone FROM '$Getdealer' WHERE (smiths_shin = 1)",$db) or die('Error retrieving Shindiawa dealers.');
echo "<TABLE BORDER=1>";
echo"<TR><TD><B>Dealer</B><TD><TD><TD><TD><TD><TD><B>Address</B><TD><TD><TD><TD><TD><TD><B>City</B><TD><TD><TD><TD><TD><TD><B>State</B><TD><TD><TD><TD><TD><TD><B>Zip Code</B><TD><TD><TD><TD><TD><TD><B>Phone Number</B></TR>";
while ($Getshin = mysql_fetch_array($Getdealer))
{
echo "<TR><TD>";
echo $Getshin["Dealer"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getshin["Address"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getshin["City"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getshin["State"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getshin["Zip"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getshin["Phone"];
}
echo "</TABLE>";
}
if ($Little)
{
mysql_query("SELECT Dealer, Address, City, State, Zip, Phone FROM '$Getdealer' WHERE (smiths_lw = 1)",$db) or die('Error retrieving Little Wonder dealers.');
echo "<TABLE BORDER=1>";
echo"<TR><TD><B>Dealer</B><TD><TD><TD><TD><TD><TD><B>Address</B><TD><TD><TD><TD><TD><TD><B>City</B><TD><TD><TD><TD><TD><TD><B>State</B><TD><TD><TD><TD><TD><TD><B>Zip Code</B><TD><TD><TD><TD><TD><TD><B>Phone Number</B></TR>";
while ($Getlittle = mysql_fetch_array($Getdealer))
{
echo "<TR><TD>";
echo $Getlittle["Dealer"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getlittle["Address"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getlittle["City"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getlittle["State"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getlittle["Zip"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getlittle["Phone"];
}
echo "</TABLE>";
}
if ($Man)
{
mysql_query("SELECT Dealer, Address, City, State, Zip, Phone FROM '$Getdealer' WHERE (smiths_m = 1)",$db) or die('Error retrieving Mantis dealers.');
echo "<TABLE BORDER=1>";
echo"<TR><TD><B>Dealer</B><TD><TD><TD><TD><TD><TD><B>Address</B><TD><TD><TD><TD><TD><TD><B>City</B><TD><TD><TD><TD><TD><TD><B>State</B><TD><TD><TD><TD><TD><TD><B>Zip Code</B><TD><TD><TD><TD><TD><TD><B>Phone Number</B></TR>";
while ($Getman = mysql_fetch_array($Getdealer))
{
echo "<TR><TD>";
echo $Getman["Dealer"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getman["Address"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getman["City"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getman["State"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getman["Zip"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getman["Phone"];
}
echo "</TABLE>";
}
if ($Class)
{
mysql_query("SELECT Dealer, Address, City, State, Zip, Phone FROM '$Getdealer' WHERE (smiths_cl = 1)",$db) or die('Error retrieving Classin dealers.');
echo "<TABLE BORDER=1>";
echo"<TR><TD><B>Dealer</B><TD><TD><TD><TD><TD><TD><B>Address</B><TD><TD><TD><TD><TD><TD><B>City</B><TD><TD><TD><TD><TD><TD><B>State</B><TD><TD><TD><TD><TD><TD><B>Zip Code</B><TD><TD><TD><TD><TD><TD><B>Phone Number</B></TR>";
while ($Getclass = mysql_fetch_array($Getdealer))
{
echo "<TR><TD>";
echo $Getclass["Dealer"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getclass["Address"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getclass["City"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getclass["State"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getclass["Zip"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getclass["Phone"];
}
echo "</TABLE>";
}
if ($Smiths)
{
mysql_query("SELECT Dealer, Address, City, State, Zip, Phone FROM '$Getdealer' WHERE (smiths_smith = 1)",$db) or die('Error retrieving Smiths dealers.');
echo "<TABLE BORDER=1>";
echo"<TR><TD><B>Dealer</B><TD><TD><TD><TD><TD><TD><B>Address</B><TD><TD><TD><TD><TD><TD><B>City</B><TD><TD><TD><TD><TD><TD><B>State</B><TD><TD><TD><TD><TD><TD><B>Zip Code</B><TD><TD><TD><TD><TD><TD><B>Phone Number</B></TR>";
while ($Getsmith = mysql_fetch_array($Getdealer))
{
echo "<TR><TD>";
echo $Getsmith["Dealer"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getsmith["Address"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getsmith["City"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getsmith["State"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getsmimth["Zip"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getsmith["Phone"];
}
echo "</TABLE>";
}
if ($Troy)
{
mysql_query("SELECT Dealer, Address, City, State, Zip, Phone FROM '$Getdealer' WHERE (smiths_troy = 1)",$db) or die('Error retrieving Troy Bilt dealers.');
echo "<TABLE BORDER=1>";
echo"<TR><TD><B>Dealer</B><TD><TD><TD><TD><TD><TD><B>Address</B><TD><TD><TD><TD><TD><TD><B>City</B><TD><TD><TD><TD><TD><TD><B>State</B><TD><TD><TD><TD><TD><TD><B>Zip Code</B><TD><TD><TD><TD><TD><TD><B>Phone Number</B></TR>";
while ($Gettroy = mysql_fetch_array($Getdealer))
{
echo "<TR><TD>";
echo $Gettroy["Dealer"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Gettroy["Address"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Gettroy["City"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Gettroy["State"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Gettroy["Zip"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Gettroy["Phone"];
}
echo "</TABLE>";
}
if ($White)
{
mysql_query("SELECT Dealer, Address, City, State, Zip, Phone FROM '$Getdealer' WHERE (smiths_white = 1)",$db) or die('Error retrieving White Outdoor dealers.');
echo "<TABLE BORDER=1>";
echo"<TR><TD><B>Dealer</B><TD><TD><TD><TD><TD><TD><B>Address</B><TD><TD><TD><TD><TD><TD><B>City</B><TD><TD><TD><TD><TD><TD><B>State</B><TD><TD><TD><TD><TD><TD><B>Zip Code</B><TD><TD><TD><TD><TD><TD><B>Phone Number</B></TR>";
while ($Getwhite = mysql_fetch_array($Getdealer))
{
echo "<TR><TD>";
echo $Getwhite["Dealer"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getwhite["Address"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getwhite["City"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getwhite["State"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getwhite["Zip"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getwhite["Phone"];
}
echo "</TABLE>";
}
if ($Oregon)
{
mysql_query("SELECT Dealer, Address, City, State, Zip, Phone FROM '$Getdealer' WHERE (smiths_oregon = 1)",$db) or die('Error retrieving Oregon dealers.');
echo "<TABLE BORDER=1>";
echo"<TR><TD><B>Dealer</B><TD><TD><TD><TD><TD><TD><B>Address</B><TD><TD><TD><TD><TD><TD><B>City</B><TD><TD><TD><TD><TD><TD><B>State</B><TD><TD><TD><TD><TD><TD><B>Zip Code</B><TD><TD><TD><TD><TD><TD><B>Phone Number</B></TR>";
while ($Getoregon = mysql_fetch_array($Getdealer))
{
echo "<TR><TD>";
echo $Getoregon["Dealer"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getoregon["Address"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getoregon["City"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getoregon["State"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getoregon["Zip"];
echo "<TD><TD><TD><TD><TD><TD>";
echo $Getoregon["Phone"];
}
echo "</TABLE>";
}
?>
</HTML>
and here is the form
<form id="form2" name="form2" method="post" action="dealerlocator/locator.php">
<table width="579">
<!--DWLayoutTable-->
<tr>
<td width="569"><label> </label>
<div align="center">
<input type="radio" name="Select Product" value="Shin" />
<img src="Images/shin.gif" alt="Shindiawa" width="95" height="33" /><span class="style1">----
<input type="radio" name="Select Product" value="Little" />
<img src="Images/little.gif" alt="Little Wonder" width="95" height="33" />----
<input type="radio" name="Select Product" value="Man" />
<img src="Images/mantis.gif" alt="Mantis" width="95" height="33" />----
<input type="radio" name="Select Product" value="Class" />
<img src="Images/classin.gif" alt="Classin" width="95" height="33" /></span></div>
<p><span class="style1">kjh lkjhlkjh kjh k </span></p></td>
</tr>
<tr>
<td><label> </label>
<div align="center">
<input type="radio" name="Select Product" value="Smiths" />
<img src="Images/smith-logo.gif" alt="Smiths" width="73" height="48" /><span class="style1">------
<input type="radio" name="Select Product" value="Troy" />
<img src="Images/troy.gif" alt="Troy Bilt" width="95" height="33" />----
<input type="radio" name="Select Product" value="White" />
<img src="Images/white.gif" alt="white Outdoor" width="95" height="33" />----
<input type="radio" name="Select Product" value="Oregon" />
<img src="Images/oregon copy.gif" alt="Oregon" width="95" height="33" /></span></div></td>
</tr>
</table>
<div class="style1">Content for New Div Tag Goes Here
<div>Content for New Div Tag Goes Here
<div class="style26"><strong>Enter Your Zip Code Here:
<label for="textfield"></label>
</strong>
<input type="text" name="formzip" id="textfield" />
<span class="style1">-----
<input type="submit" name="Submit" value="Get Dealers!" id="Submit" />
</span></div>
</div>
</div>
<p class="style1"> </p>
</form>
thank you,
Jake