Forum Moderators: coopster

Message Too Old, No Replies

Dynamic page thumbnail click

display large pic and alt tag

         

humpingdan

3:50 pm on Jan 27, 2004 (gmt 0)

10+ Year Member



Thumbnails.htm - includes this html link:

<a href="pics.php?pic=image">PIC</a>

-------------------

pics.php - includes this php/html link which creates the dynamic page,

<img src="<? echo $pic ?>.jpg">

resulting in a link which when clicked opens the picture in a dynamic page pics.php, but how can i get it to dispaly a description of the picture to, i thought there was a way of adding a alt tag to thumbnails.htm i.e :

<a href="pics.php?pic=image" alt="blah blah">PIC</a>

then in pics.php looking up the alt tag and dsiaplying it, problem is im a newbie and havent the faintest idea of how to code this? or get it to work so any help is greatfully recieved!

Dan

Birdman

4:24 pm on Jan 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The alt attribute is not accessible on the next page. However, an easy fix is to append the description to the querystring.

Example:

<a href="pics.php?pic=image&desc=My lovely picture">PIC</a>

In pics.php:

<img src="<?=$_POST["pic"]?>" />
<br />
<p>
<?=$_POST["desc"]?>
</p>

humpingdan

5:27 pm on Jan 27, 2004 (gmt 0)

10+ Year Member



quality, love this place

sorry i dont seem to be able to get it to wrok, where do i put the url of the image?

Birdman

6:19 pm on Jan 27, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<a href="pics.php?pic=URL_OF_IMAGE&desc=My lovely picture">PIC</a>

Try that.

humpingdan

8:31 pm on Jan 27, 2004 (gmt 0)

10+ Year Member



apologies, after posting that i realised u r the don at this kinda thing!

thanks

humpingdan

9:17 am on Jan 28, 2004 (gmt 0)

10+ Year Member



its still not working yet?

Birdman

9:27 am on Jan 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Dan,

Sorry to sound sarcastic in me earlier response. I didn't mean it to be :)

What happens when you try the script?

Do you get any errors?

Birdman

humpingdan

10:46 am on Jan 28, 2004 (gmt 0)

10+ Year Member



the script runs ok, but the picture doesnt appear and neither does the desciprtion,

this is what ive done to over come this problem,

.htm file

<a href="pics.php?pic=apple&desc=apple">PIC</a>

.php file

<img src="<? echo $pic?>.jpg">
<br>
<? echo $desc?>

which works!

what is the best way to learn php?

Birdman

11:04 am on Jan 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sorry, I messed you up on the $_POST part. It should have been $_GET["pic"]. Since using the variable name alone(without using superglobal $_GET,$_POST etc.) works for you, you can leave that out.

It is a good habit to use the superglobal to access variables in forms and querystrings because one day you might move to another server which may have auto-globals turned off. Then, you would have to change all of your scripts.

If you plan to have alot of images and descriptions, you may want to think about using a database to store your image descriptions. It has a few benefits, like being able to run searches on all your image descriptions for certain keywords and also categorizing them.

For learning PHP, I like the manual at php.net. Always read the user notes at the bottom too, they can be helpful.

This forum is also a great place to learn.