ripcurlksm
10-24-2007, 02:08 PM
I am trying to create an image array where it will load the first image in the array, and if a user clicks the 'Next Image' button, it will go to the next image in the array. When the user views the last image and clicks next, it should go back to the first image.
I need help (1) revising my array (2) building a loop to cycle through the images.
Here is my image table
id | path | caption
---------------------------------------------------------------
1 | image1.jpg | This is caption #1
1 | image2.jpg | This is caption #2
2 | image3.jpg | This is caption #3
3 | image4.jpg | This is caption #4
$query = "SELECT * FROM images WHERE id='1'";
$result = mysql_query($query) or die(mysql_error());
///////////////////////////////
//////////BUILD ARRAY //////
///////////////////////////////
while (mysql_fetch_array($query))
{
$pics[] = array(
'id' => $pics['id'],
'path' => $pics['path'],
'caption' => $pics['caption']
);
}
///////////////////////////////
//////////BUILD LOOP ///////
///////////////////////////////
// I really need help with this part -- if a user clicks the 'Next Image' button, it will go to the next image in the array.
for each (x as y){
<a href="$pics['path']">Next Photo</a>
}
I need help (1) revising my array (2) building a loop to cycle through the images.
Here is my image table
id | path | caption
---------------------------------------------------------------
1 | image1.jpg | This is caption #1
1 | image2.jpg | This is caption #2
2 | image3.jpg | This is caption #3
3 | image4.jpg | This is caption #4
$query = "SELECT * FROM images WHERE id='1'";
$result = mysql_query($query) or die(mysql_error());
///////////////////////////////
//////////BUILD ARRAY //////
///////////////////////////////
while (mysql_fetch_array($query))
{
$pics[] = array(
'id' => $pics['id'],
'path' => $pics['path'],
'caption' => $pics['caption']
);
}
///////////////////////////////
//////////BUILD LOOP ///////
///////////////////////////////
// I really need help with this part -- if a user clicks the 'Next Image' button, it will go to the next image in the array.
for each (x as y){
<a href="$pics['path']">Next Photo</a>
}