I have an array holding some image names. I want to set it up so when the user hits refresh it loads the next image in the array.
Example: I am looking at a page with img_2.jpg displayed. I hit F5 for refresh and the page reloads with img_3.jpg. I hit F5 again and the page reloads with img_4.jpg. etc.
The array is set up as follows:
PHP Code:
<?php
$picturesArray = array("img_1.jpg", "img_2.jpg",
"img_3.jpg", "img_4.jpg", "img_5.jpg", "img_6.jpg",
"img_7.jpg","img_8.jpg", "img_9.jpg","img_10.jpg",
"img_11.jpg","img_12.jpg", "img_13.jpg","img_14.jpg",
"img_15.jpg");
echo "<img class=\"main_img\" src=\"../images/comps/$picturesArray[0]\"";
echo " alt=\"Turned My Life Around\" >";
?>
I am thinking I need to set a variable - $pict_no and initialize it to "0"
Then I need to change the echo statement above to use the $pict_no for the array value to be displayed.
Then increment $pict_no by 1
And then when they hit refresh, send the new incremented $pict_no to the next page.
So assuming I can figure out the increment part, how do I send the new value to be used in the next page?