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
https://forums.phpfreaks.com/topic/61551-solved-assigning-values-within-href/
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.

 

 

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.