Using Next/prev Button To Display Array Elements

A Member? Please Login  
type your username and password to login
Date: October 07, 2008, 05:00 AM
246929 members and 145851 Topics
Latest Member: osas 333
Nairaland [Nigerian Forum] Home Help Search Who is currently online? Login Register
Nairaland Forum  |  Technology  |  Programming  |  Using Next/prev Button To Display Array Elements
Pages: (1) Go Down Send this topic Notify of replies
Author Topic: Using Next/prev Button To Display Array Elements  (Read 234 views)
cnn
Using Next/prev Button To Display Array Elements
« on: November 20, 2006, 05:57 PM »

Hi all;
I am newbie in php. I have array of 5 pictures. i want to display one picture at a time by clicking next or previous button. however, i'm able to display different pictures if I shuffle the elements of the array, but I want to display the images starting from the first element as I click the next button.  I appreciate any suggestion on how to do it. I am using php5.
Thanks  Embarrassed
cnn
Re: Using Next/prev Button To Display Array Elements
« #1 on: November 21, 2006, 08:30 AM »

Thank you very much Prodgalson for given me your precious time,
I want to display only one image  starting from the first  when I click Next and the previous image when I click  prev button but it is not done in the order in which the images are placed in the array.
This is the code i used to select the images.

<body>
<table border="0" align="center">
 <?php
   $im0 = "<img src = './pic/car.gif' width = '150' height = '150'>";
   $im1 = "<img src = './pic/fl.jpg' width = '150' height = '150'>";
   $im2 ="<img src = './pic/house.jpg' width = '150' height = '150'>";
   $im3 = "<img src = './pic/phone.gif' width = '150' height = '150'>";
   $im4 = "<img src = './pic/pope.jpg' width = '150' height = '150'>";
   $image = array($im0, $im1, $im2, $im3, $im4);
   shuffle($image);
echo next($image); 
 ?>
 </td></tr></table> 
 <table align="center" border="0">
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
 <input type ="submit" value ="Previous" name="prv">
 &nbsp;<input type="submit" value="Next"  name="nxt" />
 </form>
 </td></tr></table>
</body>
I appreciate any suggestion on how best to do it.
Cnn
cnn
Re: Using Next/prev Button To Display Array Elements
« #2 on: November 21, 2006, 09:28 PM »

Thank you once more Prodgalson;
What I want to do is to display the elements of the array starting from the second one when I click Next button but I ended up displaying only the second element. so in attempt to display other elements from the array I decided to shuffle the elements. So I still beg for complete solution
 In Need Of A Career Mentor (programming ).  Want To Hide Ip  Can Apache And Iis Run Of The Same Machine?  Page 2
Pages: (1) Go Up Send Topic to Friend by E-mail Reply 
Google
 
Web www.nairaland.com
Sections: TV/Movies (2) Music/Radio (2) Celebrities Job Talk Jobs/Vacancies (2) Career Talk Romance Books Politics Sports Fashion Travel
Health Schooling Religion General(2) Business Webmaster Programming Computers Phones Cars & Trucks

Links: Page1 Page2 Page3 Page4 Page5 Page6 Page7 Page8 Page9 Page10

Nairaland is owned by Oluwaseun Osewa
Nairaland Forum | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.