Zeroshade Posted December 10, 2006 Share Posted December 10, 2006 Is it possible to say if this link is clicked then something happens? if so, how can i say the if this link is clicked because i know what will happen ^_^? Link to comment https://forums.phpfreaks.com/topic/30083-resolved-saying-if-this-is-clicked/ Share on other sites More sharing options...
fert Posted December 10, 2006 Share Posted December 10, 2006 you mean like<a href="page.php?link=1">Click[/url]page.php[code]if($_GET['link']==1){echo "you clicked on link one";}[/code] Link to comment https://forums.phpfreaks.com/topic/30083-resolved-saying-if-this-is-clicked/#findComment-138273 Share on other sites More sharing options...
Zeroshade Posted December 10, 2006 Author Share Posted December 10, 2006 Not exactly but if it points to the an html file then would it still work? Link to comment https://forums.phpfreaks.com/topic/30083-resolved-saying-if-this-is-clicked/#findComment-138274 Share on other sites More sharing options...
fert Posted December 10, 2006 Share Posted December 10, 2006 what do you mean 'if it points to an HTML file'? Link to comment https://forums.phpfreaks.com/topic/30083-resolved-saying-if-this-is-clicked/#findComment-138275 Share on other sites More sharing options...
Zeroshade Posted December 10, 2006 Author Share Posted December 10, 2006 This is my goal. I want a picture to be displayed. If the picture is clicked then the first picture will equal the second picture which then equals a whole new picture and therefore displays the new picture instead. So basically I want a slideshow. Can I do this? Link to comment https://forums.phpfreaks.com/topic/30083-resolved-saying-if-this-is-clicked/#findComment-138276 Share on other sites More sharing options...
Zeroshade Posted December 10, 2006 Author Share Posted December 10, 2006 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 https://forums.phpfreaks.com/topic/30083-resolved-saying-if-this-is-clicked/#findComment-138291 Share on other sites More sharing options...
trq Posted December 10, 2006 Share Posted December 10, 2006 [quote]Can this be adapted somehow?[/quote]No.. that code makes little sense.Explain exactly what it is you want to do, or if its a simple slideshow even better, search for a tutorial. Link to comment https://forums.phpfreaks.com/topic/30083-resolved-saying-if-this-is-clicked/#findComment-138297 Share on other sites More sharing options...
Zeroshade Posted December 10, 2006 Author Share Posted December 10, 2006 if the picture is clicked then the $picture will equal another picture and then show that instead. Any ideas? Link to comment https://forums.phpfreaks.com/topic/30083-resolved-saying-if-this-is-clicked/#findComment-138299 Share on other sites More sharing options...
phil.t Posted December 10, 2006 Share Posted December 10, 2006 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 https://forums.phpfreaks.com/topic/30083-resolved-saying-if-this-is-clicked/#findComment-138387 Share on other sites More sharing options...
Zeroshade Posted December 11, 2006 Author Share Posted December 11, 2006 what has to be in the php file? Link to comment https://forums.phpfreaks.com/topic/30083-resolved-saying-if-this-is-clicked/#findComment-138763 Share on other sites More sharing options...
Zeroshade Posted December 11, 2006 Author Share Posted December 11, 2006 oh, u mean keep this out of the html and make an external with this in it. ok. Link to comment https://forums.phpfreaks.com/topic/30083-resolved-saying-if-this-is-clicked/#findComment-138765 Share on other sites More sharing options...
Zeroshade Posted December 11, 2006 Author Share Posted December 11, 2006 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 https://forums.phpfreaks.com/topic/30083-resolved-saying-if-this-is-clicked/#findComment-138770 Share on other sites More sharing options...
trq Posted December 11, 2006 Share Posted December 11, 2006 [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 https://forums.phpfreaks.com/topic/30083-resolved-saying-if-this-is-clicked/#findComment-138772 Share on other sites More sharing options...
Zeroshade Posted December 11, 2006 Author Share Posted December 11, 2006 i think as long as i keep the pics closer to the top of the page then the users wouldn't notice it refresh... thank u all for ur help! Link to comment https://forums.phpfreaks.com/topic/30083-resolved-saying-if-this-is-clicked/#findComment-138774 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.