Jump to content

[ resolved ] saying if this is clicked?


Zeroshade

Recommended Posts

Can this be adapted somehow?

[code]<?php
                                                        $picture = "images\blue-carry.jpg";
                                                        echo "<a href='images\blue-carry.jpg?link=1'><img src='$picture' /></a>";
                                                        if($_GET['link']==1)
{
                                                        $picture = "images\blue-ebook.jpg";
echo "<img src='$picture' />";
}
                                                ?>[/code]
Link to comment
Share on other sites

I would recommend that you store the image paths in a numbered array, and increment through them one by one as the images are clicked.

Here's an example:

[code]
<?php

$photos = array (1=>'img/photo_1.jpg', 'img/photo_2.jpg', 'img/photo_3.jpg', 'img/photo_4.jpg');

$curPic = $_GET['id'] + 1;

if ($curPic < 5)
   echo '<a href="slideshow.php?id=' . $curPic . '"><img src="' . $photos[$curPic] . '" /></a>';
else
   echo '<p>End of Show</p>';

?>

[/code]

The id displayed in the URL will be one behind the index of the picture actually being displayed.  If that bothers you, then you can modify where you actually increment your index value.  In case it isn't obvious, replace 'slideshow.php' with whatever you name your php file.
Link to comment
Share on other sites

I'm not understanding the link. If i point it to the slideshow.php then it opens up a new page. if i take it out like so... it'll refresh the page with the new picture. How can i keep it from acutally refreshing?
[code]<?php
                                                        $picture = array (1 => 'images\blue-carry.jpg', 'images\blue-ebook.jpg');
$curPic = $_GET['id'] + 1;
if ($curPic < 3)
echo '<a href="?id='.$curPic.'"><img src="'.$picture[$curPic].'" /></a>';
else
  echo '<p />End of Show';
                                                ?>[/code]
Link to comment
Share on other sites

[quote]How can i keep it from acutally refreshing?[/quote]

You cant. A request needs to be made to the server and the server needs to send the response. Of course you could use some Ajax trickery but thats a whole other beast not really in the scope of this forum.
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.