appending php variables to a html url

Hi,
I have 2 php files located at
www.blossompark.net/firstpage.php
www.blossompark.net/secondpage.php
(code for both files below)
when the link on www.blossompark.net/firstpage.php is used it sends a predefined query string to www.blossompark.net/secondpage.php...
the secondpage.php file creates a variable "coordinates" from the query string.
I now want  to append that data (which is a set of google gps coordinates) to a html url on the same page. I'm having difficulty appending this data which should end up creating the following url;
http://maps.google.com/maps?q=53.290208540067006 -6.274996866083001

Ive tried  putting in on secondpage.php
<a href="http://maps.google.com/maps?q=<?php $_GET['q'] ?> " > Current Location < /a>
put it completely ignores the php
how can i reference the contents of the coordinates variable from within the html url?
thanks ...first time with php and html here...go easy!!!
<html>
	<head>
		<title>First Page</title>
	</head>
	<body>
		<a href="secondpage.php?q=53.290208540067006 -6.274996866083001" >send url from phone simulation
	</body>
</html>


<html>
	<head>
		<title>Second Page</title>
	</head>
	<body>
	<?php  
         print_r($_GET);
         $coordinates = $_GET['q'];
          echo " <br /> $coordinates ";
         ?>
          <br/>
          <a href="http://maps.google.com/maps?q= " >Current Location
	
</body>
</html>

Open in new window

blossomparkAsked:
Who is Participating?
 
HackneyCabCommented:
Change the embedded PHP statement to this:

<?php echo $_GET['q'] ?>

Without the echo command, PHP doesn't do anything with the value of the $_GET['q'] variable.
0
 
Mark BradyPrincipal Data EngineerCommented:
On line 18 you capture the information in the  $coordinates variable so you can use that in your link like this:


?>
<a href="http://maps.google.com/maps?q=<?php echo $coordinates;?>Current Location</a>

Like HackneyCab said, if you don't use "echo" before the variable you want to insert it will do nothing.
0
 
blossomparkAuthor Commented:
thanks HackneyCab!! works 100% !!
0
 
blossomparkAuthor Commented:
thanks Elvin66...sorry only noticed your reply after having responded to HackneyCab
0
 
Mark BradyPrincipal Data EngineerCommented:
No problem
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.