Jump to content

[SOLVED] Assigning values within href


jseaman

Recommended Posts

I'm having a hard time finding information (probably due to how I'm phrasing my searches) on how to assign a variable to an href.

 

The big picture is I have a bunch of photos I'm trying to put on my website.  I have an equally large bunch of thumbnails with links, all to the same page (pictures.php) that has a snippet of php (seen below).  In my links I am attempting to assign a value to a variable that corresponds with a picture.

 

Here is the php snippet in pictures.php:

 

<?php

echo '<img src=images/'. $picture. '.jpg>';

?>

 

Now, this is how my href looks on the page with all the thumbnails:

<a href="index.php?page=pictures.php" name="picture" value="pic001">[thumbnail]</a>

 

My php is fine, when I look at the source on the web it looks like <img src=images/.jpg>.  So the problem obviously lies in how I'm doing my link.  My questions are, can I do what I'm trying to do?  If so, how?  If not, what's another similar method I can do to make this work?

Link to comment
Share on other sites


Hey,

 

It doesn't look like you have any code grabbing the page=picture.php, which would be a $_GET


, if echo'd would be picture.php

 

You could set different variables and use an if:

 

$test = $_GET


 

if($test == "one")

{

$picture = "matt.jpg";

}else{}

 

Then $picture would have a value of matt.jpg

 

It just looks like your trying to pass a variable that isn't being defined.

 

 

Link to comment
Share on other sites

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.