Jump to content

How do I retrieve variables passed thru the URL?


ridiculous

Recommended Posts

Hi. I'm trying to pass variables through an image link like so:

===================================================================

echo       
'<div>
<a href="course_details_index.php?
'.$Course_Id.'
&'.$Course_Begin_Time.'
&'.$Instructor_1.'">
<img src="media/course_pics/'.$Course_Pic .'" alt="Featured Course Image" border="none"
img style="position:absolute; height:300px; width:300px; TOP:0px; LEFT:0px;"></a>
</div>';


=====================================================================

When I pass the variables through the link, they come out as raw data on the address bar of the target page, and I get nothing when I try to print or echo them.


print $Course_Id;      = Blank Space

echo $Course_Id;      = Blank Space



How do I fix this so that I can print the variables out as needed or have them available to run a mysql query?

echo     
      '<div>     
      <a href="course_details_index.php?
      '.$Course_Id.'
      &'.$Course_Begin_Time.'
      &'.$Instructor_1.'">
      <img src="media/course_pics/index.php?pic='.$Course_Pic .'" alt="Featured Course Image" border="none"
      img style="position:absolute; height:300px; width:300px; TOP:0px; LEFT:0px;">[/url]
      </div>';

=====================================================================

echo $_GET['pic'];
That all looked kinda messy to me so I'll just repost :) :

If your requesting url looks like:

[color=blue]http://mydomain.com/index.php?name=bob&id=123[/color]

Then, you'd retrieve the value of that variable like so:

[code]<?php

$myname = $_GET['name'];
$myid = $_GET['id'];

echo"My name is $myname and my id number is $myid, sucka!!";

?>[/code]
1) You haven't set the variable in the URL.
2) You haven't told it to get the variable from the URL.

Create the URL:
[code]
<?php
echo     
      '<div>     
      <a href="course_details_index.php?
      Course_Id='.$Course_Id.'
      &Course_Begin_Time='.$Course_Begin_Time.'
      &Instructor_1='.$Instructor_1.'">
      <img src="media/course_pics/'.$Course_Pic .'" alt="Featured Course Image" border="none"
      img style="position:absolute; height:300px; width:300px; TOP:0px; LEFT:0px;">[/url]
      </div>';
?>
[/code]

Then in the page that is called from that link:

[code]
<?php
  echo '<br />" . $_GET['Course_Id'];
  echo '<br />" . $_GET['Course_Begin_Time'];
  echo '<br />" . $_GET['Instructor_1'];
?>
[/code]
Can you try this...
echo       
      '<div>     
      <a href="course_details_index.php?Course_Id=
      '.$Course_Id.'
      &Course_Begin_Time='.$Course_Begin_Time.'
      &Instructor_1='.$Instructor_1.'">
      <img src="media/course_pics/'.$Course_Pic .'" alt="Featured Course Image" border="none"
      img style="position:absolute; height:300px; width:300px; TOP:0px; LEFT:0px;">[/url]
      </div>';

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.