Page 1 of 1
.php to mapquest
Posted: Mon Jan 17, 2005 12:27 am
by dino3
I am a student and I was stuck with the task of coding a .php database structure for my group with out any knowlage besides some books, I have read php for the world wide web, php for dummies, and mysql/php database applications, and I am trying to figure out how to code a php document that will look into my database file with zipcodes in it, and will, after doing some inhouse math, send you to mapquest to show a map based off of a user inputted zipcode (this is for a chain of diners) what it will do is take the inputted zipcode, and based off the database, will do the math to figure out what is closer and then send you to mapquest.
Thanks
Dino
Posted: Mon Jan 17, 2005 1:19 am
by feyd
what specific parts do you need guidance with?
what I dont understand
Posted: Mon Jan 17, 2005 1:34 am
by dino3
[<?php
$Mlink = "";
;
$zip = trim($zip);
$Mlink = "
http://www.mapquest.com/maps/map.adp?ad ... =us&zoom=5";
return $Mlink;
}
?>
is what I have (I found it online and been playing around with it)
, I have tired using html to have it link after putting in a zipcode, but nothing happens.
Posted: Mon Jan 17, 2005 1:42 am
by feyd
$Mlink does not reference $zip anywhere in it's string.
thanks
Posted: Mon Jan 17, 2005 1:50 am
by dino3
I cant believe I missed that, ilike I said, I found some old code,
Thanks again Mate
dino
Posted: Mon Jan 17, 2005 1:53 am
by feyd
the (hopefully) less bleary eyes of another developer almost always help..

Glad it was an easy one.. so far

Here is what I have so far
Posted: Mon Jan 17, 2005 1:57 am
by dino3
I am sorry to be taking up your time mate, but here is what I have so far...
[<form>
<h1> Zip Code</h1>
<form name= "zip" id"zip"
method="zip" action="zips.php">
<p>Please insert your Zip Code <br />
<textarea name="Zips" cols "10"
rows="0"id= "$zip"></textarea>
</p>
$Mlink = "";
;
$zip = trim($zip);
$Mlink = "
http://www.mapquest.com/maps/map.adp?address=$zip";
return $Mlink;
}
</form>
]
Posted: Mon Jan 17, 2005 2:12 am
by feyd
the basic html should look this (zips.php):
Code: Select all
<?php
if(!isset($_GETї'zip']) || !is_numeric($_GETї'zip']))
{
echo <<<STOP
<form method="get" action="zips.php">
<input type="text" name="zip" maxlength="5" />
<input type="submit" value="Find Closest Store" />
</form>
STOP;
exit;
}
// do your distance calculations in here
// assume $zip is the location chosen from the calculation
$Mlink = 'http://www.mapquest.com/maps/map.adp?address=' . $zip;
echo 'Closest found: <a href="' . $Mlink . '">' . $zip . '</a>';
Life saver
Posted: Mon Jan 17, 2005 2:18 am
by dino3
Thank you so much man, you have no Idea how much you have helped me,
dino