Jump to content

Recommended Posts

I have a field in my database "number_photos" and lets say for example that number is 4.

 

I want to make it so if # of photos = 4, it will display:

 

photo_0.jpg

photo_1.jpg

photo_2.jpp

photo_3.jpg

 

I was going to use foreach to do this, but it does not work / I don't think it is the correct way.

 

So next I thought I would do:

 

$p = # of photos
$p++

 

To count up - but I need it to start at 0, and also need it to display the photo_0.jpg, etc.

 

I am stuck. Any suggestions?

Using the following:

 

<?php

$number = $page['details']['NO_PHOTOS'];

//The loop.

for($i=0; $i<$number; $i++){
$image[$i] = "photos[$i]=\"dir/medium/".substr($page['details']['LIST_NO'], 0, 2)."/".substr($page['details']['LIST_NO'], 2, 3)."/".substr($page['details']['LIST_NO'], 5, 3)."_".$i.".jpg\"";

}

//Display everything.

foreach($image as $key=>$val){
echo $val."<br />";
}

?>

 

I get the error: "Invalid argument supplied for foreach() in ...

 

Do you know the issue?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.