Page 1 of 1

random... list... mess.

Posted: Sun Oct 17, 2004 5:17 pm
by Daisy Cutter
okay i have a list of random images and urls right now. it's huge so I put it's source at:

http://kafene.org/randimgsrc.txt

I want to do this:
keep the array for the random images.
Change the if/else business to a corresponding array so that they match up
generate a list of all these images (so that rather than being random, they all just dump into the form <a href="$url"><img src="$img" alt="img" />

OR what I think is easier AND better:
take the contents of an entire directory, make the images named like imagename.com.png and then randomly get one, put it in the form <a href="http://www. $imagename - .png"><img src="$imagename" alt="img" /></a>...

If you can just give an example for either I should be able to work from there.

EDIT:
the directory listing I would want in that format is http://kafene.org/img/ .
i realize i would have to change the filenames.

Posted: Sun Oct 17, 2004 6:21 pm
by Daisy Cutter
ok i've been thinking about this...

for the second one where I got a plain directory listing and used it almost like a flat file database:

I could use a for loop and this code:

Code: Select all

<?php
if ($handle = opendir('/home/mcovey/kafene.org/img')) {
   echo "Directory handle: $handle\n";
   echo "Files:\n";

   while (false !== ($file = readdir($handle))) { 
       echo "$file\n";
   }

   closedir($handle); 
}
?>
and then use something like sed (but in PHP) to search for and output results...

Posted: Mon Oct 18, 2004 4:27 pm
by Daisy Cutter
can anyone help me here?

Posted: Mon Oct 18, 2004 4:57 pm
by feyd
I'd use a database table to store the url/image location information.

Posted: Mon Oct 18, 2004 8:39 pm
by Daisy Cutter
feyd wrote:I'd use a database table to store the url/image location information.
hm.. that just seems so big for what i'm doing. Is there any way to use sed through PHP? In that case the rest would be fairly simple, otherwise I'll just stick with using my array and conditionals.

Posted: Mon Oct 18, 2004 10:11 pm
by feyd
you can always just have a flat file of the linkage information concerning the known files in the folder. You'll have to verify that the files still exist each time you open the file, in case one gets deleted.