Adjusting PHP Code for Photo Gallery
April 30, 2008 12:54 PM   Subscribe

Non-programmer needs help with some PHP code for an online gallery.

I'm doing a favor for a friend, and creating a simple portfolio site. I downloaded a cool bit of code that will let you dump images and descriptions (as text files with the same names), in a directory and have a gallery created - I'm basically creating a gallery for each piece of this artists' work, to show a main image and have several clickable thumbs that give alternate views - I'd like to force the first image in each discreet gallery to open whenever someone visits that gallery, but it looks like it's set to random. Here's what I think is the relevant part:

$rand_class=""; $rand_caption=""; // zero some stuff out
$rand_img = $a_img[mt_rand(0, $tot_img-1)]; // grab a random starting image...
$rand_caption = $desc_img[$rand_img]; // ...and it's caption if it exists
$rand_class= ($rand_caption!="")?"asdasd":"hidden"; // if it exists, we'll want to show it.

How can I adjust that second line to not grab a random image, but always go to the first?
posted by jalexei to Computers & Internet (4 answers total) 1 user marked this as a favorite
 
I don't know PHP in particular, I'm going to guess you want to change the second line to:

$rand_img = $a_img[0]; // grab the first image
posted by enn at 1:01 PM on April 30, 2008


I know PHP. enn is absolutely correct.
posted by le morte de bea arthur at 1:04 PM on April 30, 2008


Ditto le morte.
posted by cgg at 1:11 PM on April 30, 2008


Response by poster: Worked like a charm! - Thanks folks, you've saved the right-brained designer from a giant "I don't understand this gibberish" headache.
posted by jalexei at 1:15 PM on April 30, 2008


« Older Anything other than Contiki?   |   Tanzania visa validity Newer »
This thread is closed to new comments.