build a URL with variables in it

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lcp
Forum Newbie
Posts: 2
Joined: Fri May 02, 2008 12:08 am

build a URL with variables in it

Post by lcp »

Hi, I would like to include variables into a URL that I am passing to Yahoo Pipes. In the URL below, I would like to have a variable for EndTime (set below to yesterday) and StartDate (set below to 15+days).
http://pipes.yahoo.com/pipes/pipe.run?EndDate=yesterday&StartDate=%2B15+days&_id=84&_render=kml

This URL is being passed in my html code that generates a google map:
var geoXml2 = new GGeoXml(http://pipes.yahoo.com/pipes/pipe.run?EndDate=yesterday&StartDate=%2B15+days&_id=23e0135e18323711db0d9db51ccca684&_render=kml;

If I could assign the EndTime and StartTime to variables, then I could control what comes back from the Yahoo Pipe onto the map. I think php is the right way to do this, but I'm not sure how.
Thanks!
Last edited by lcp on Fri May 02, 2008 4:21 pm, edited 1 time in total.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: build a URL with variables in it

Post by Christopher »

Code: Select all

echo "var geoXml2 = new GGeoXml('http://pipes.yahoo.com/pipes/pipe.run?EndDate=$enddate&StartDate=$startdate&_id=$id&_render=kml')";
(#10850)
User avatar
Kastor
Forum Newbie
Posts: 24
Joined: Thu May 01, 2008 2:29 am
Location: Grodno, Belarus
Contact:

Re: build a URL with variables in it

Post by Kastor »

Code: Select all

 urlencode("http://pipes.yahoo.com/pipes/pipe.run?EndDate={$enddate}&StartDate=$startdate&_id={$id}&_render=kml");
youscript
Forum Newbie
Posts: 10
Joined: Thu Sep 13, 2007 3:22 am

Re: build a URL with variables in it

Post by youscript »

Also can use the function rawurlencode to bulid it
lcp
Forum Newbie
Posts: 2
Joined: Fri May 02, 2008 12:08 am

Re: build a URL with variables in it

Post by lcp »

Hi, thanks for the help. This is how I solved it:
The code below is in the middle of regular html but the file ends in .php. I guess the browser just reads the page as html. This is set up so that when the URL to the .php page has the variables of start, end, etc in the URL that it populated the Yahoo Pipes URL in the php code:
www.example.com/gmaps.php?start=15&end=yesterday&fname=Joe&lname=Blow&zip=11111

Next step is to figure out how to make a web form that fills the variables. Any ideas?

<?
$enddate = $_REQUEST['end'];
$startdate = $_REQUEST['start'];
$fname = $_REQUEST['fname'];
$lname = $_REQUEST['lname'];
$zip = $_REQUEST['zip'];

echo "var geoXml2 = new GGeoXml(\"http://pipes.yahoo.com/pipes/pipe.run?EndDate=$end&Firstname=$fname&Lastname=$lname&StartDate=%2B$start+days&Zip=$zip&_id=84&_render=kml\");";
?>
Post Reply