[Cialug] RE: Cialug digest, Vol 1 #1087 - 5 msgs

Nathan C. Smith cialug@cialug.org
Fri, 5 Nov 2004 11:25:11 -0600


I know ColdFusion better than PHP.

I would do a directory on the files.  In CF the directory contents becomes
accessible as a SQL query result, in PHP I assume it becomes an array or the
good parts could be placed in an array.  Then for each picture you want
search the array, if the file isn't there, show your "no picture available"
picture instead.  Unless the directory is huge and kills your memory, this
will be faster than doing a disk read each time.

see
opendir()
readdir()
closedir()

I wonder if there is a PEAR function that makes this super-easy?

-Nate

-----Original Message-----
From: Andrew Lietzow [mailto:alietzow@myfamily.com] 
Sent: Friday, November 05, 2004 11:12 AM
To: cialug@cialug.org
Subject: [Cialug] RE: Cialug digest, Vol 1 #1087 - 5 msgs


Hello LAMP brainiacs. I Need help with "if then else" logic in with PHP and
HTML. 

Here is a page that lists some plants. 
http://hostahaven.com/pages/whatsnew/HH_ID.php

For some of the items, I have a photo while for others, I have not at
present.  I'd like to add a conditional statement that checks for the
existence of the jpg file in the appropriate directory, and if it doesn't
exist, print the text "No Photo" rather than "Click for Photo". 

I assume I can do some kind of file checking, like 
$file=fopen("foo","r") or die("Error!"); 
but I'm a bit lost on what to do.  

This tutorial gets me close to an answer (e.g.
http://www.htmlgoodies.com/php/p11filesystem.html) but doesn't clarify how I
check for a file in a particular directory.  

Hints will be appreciated.   :-)  
Andrew Lietzow
 
     


_____________________________________________________________________
Get your own family web site at www.MyFamily.com!