On Click

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
yasirjamal
Forum Newbie
Posts: 8
Joined: Tue Feb 10, 2009 11:05 pm

On Click

Post by yasirjamal »

Dear Friends,


I am making a website. But language is not in english or not compatible with dreamweaver.
So i have to make images as a text for that website. The images are 30 before its was just only HTML website. 30 images means 30 HTML Pages. It was very difficult for me to arrange 30 HMTL pages. I want when i click to a button the images will be call from images folder on same page. When i click to next button next images will be call from images folder. Can you anyone tell me please how to do it.

Thank You
Randwulf
Forum Commoner
Posts: 63
Joined: Wed Jan 07, 2009 7:07 am

Re: On Click

Post by Randwulf »

I hope I understand what it is you're looking for.

Code: Select all

 
<?php
if (!isset($_GET['pic'])) $pic = 0;
else $pic = $_GET['pic'];
$ar = scandir("images folder here");
echo "<img src='images folder path here/".$ar[pic]."'>";
echo "<a href='filenamehere.php?pic=" . $ar[pic] + 1 . "'>Next</a>";
 ?>
 
yasirjamal
Forum Newbie
Posts: 8
Joined: Tue Feb 10, 2009 11:05 pm

Re: On Click

Post by yasirjamal »

Dear Randwulf,

I dont want a image gallary. please visit http://www.saughat.com.
In this website the right side. There are some button when you click a button image will be open on a position. I want when i click to 1 button 1 image will be open when i click 2 image 2 will be open.
Randwulf
Forum Commoner
Posts: 63
Joined: Wed Jan 07, 2009 7:07 am

Re: On Click

Post by Randwulf »

So you want the picture to be opened in the center of the main page instead of you having to make a whole bunch of different html pages that the buttons link to. I think I understand now.

You would turn your main page into a PHP page and pass the picture file name to the page with GET. Each of your buttons in this case would link to http://www.saughat.com/saughat/index.ph ... lename.jpg. (Where insertfilename.jpg is replaced with the picture name of course)

Code: Select all

 
<?php
if (!isset($_GET['pic'])) $fileloc = "images/defaultpicname";
else $fileloc = "images/" . $_GET['pic'];
?>
---HTML Stuff Here---
 
<image src="<?php echo $fileloc; ?>">
 
---More HTML Stuff---
 
Post Reply