Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,152,076 members, 7,814,737 topics. Date: Wednesday, 01 May 2024 at 06:30 PM

Using Next/prev Button To Display Array Elements - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Using Next/prev Button To Display Array Elements (3072 Views)

Join The Clarion Call: Seun, Add A 'dislike' Button To Every Topic Or Post / Vb.net Code To Display Image In Picturebox From Sql Server / Converting Picture To Byte Array(blob) And Back To Picture (2) (3) (4)

(1) (Reply)

Using Next/prev Button To Display Array Elements by cnn: 5:57pm On Nov 20, 2006
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  embarassed
Re: Using Next/prev Button To Display Array Elements by cnn: 8:30am On Nov 21, 2006
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
Re: Using Next/prev Button To Display Array Elements by cnn: 9:28pm On Nov 21, 2006
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

(1) (Reply)

I Want To Learn Programming, What Are The Things Needed As A Beginner / Intern As Front End Developer Without Pay!! / Hiring Full-time Remote React.js Developers

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 17
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.