Jump to content

hemerocallis

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

hemerocallis's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Wow, quick replies. An array definitely makes more sense, I'll get on it. Thanks guys!
  2. Hey everyone, I'm new to PHP so excuse me if this is an obvious question: I've got a horizontal scrolling image gallery as an include, as it will be used in dozens of pages. Each page that includes the image gallery will be using different pictures and in different numbers (anywhere from 1 - 15 images). In each page that includes the image gallery, I've turned each image to be used into a variable.. $image 1 = "images/image1.jpg"; $image 2 = "images/image2.jpg"; ... $image 7 = "images/image7.jpg"; etc. Now, I imagine I need to write a loop in the include that will account for as many pictures as there are variables in each page, without adding links for variables that aren't in the page in question. Something like (simplified): Defined on page: $image 1 = "images/image1.jpg"; $image 2 = "images/image2.jpg"; $image 3 = "images/image3.jpg"; $image 4 = "images/image4.jpg"; Loop in photo gallery include: <?php for($i = 1; $i <=15; $i++) { $imagei = ("$" ."image".$i); if (defined($imagei)) { echo '<li><a href="' .$imagei.'">'; echo '<img src=" '.$imagei.'" >'; echo '</a></li>'; } } ?> I know this doesn't work because $imagei isn't referring to the defined variables on the external page, but I'm not sure exactly where to go from here. As in, $imagei in the first execution of the loop is equal to "$image1", but how do I link that to the $image1 variable defined in the page (as "image/image1.jpg") to display the image? Does that make sense? Thanks!
×
×
  • 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.