Jump to content

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]
Well I see an error in my code.  I mixed quote types.

In the second bit of code:
[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>';
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.