Just in case you were still looking for info on your question, I've put all of the code from a page I have working that does pretty much what you're looking for. I'm no guru, but the code is commented pretty well. The page does a little more than what you have mentioned you're looking for, but maybe some of the "extras" will be of use to you.
############################################################################ ## <?php //This'll be a template page to be used as a basis for a content area that's just open and waiting to be filled in with text or a custom table. echo(" <div class='content'> "); //set the directory. needs to be pulled in as a variable from a menu choice or previous page $dir = $incomingDirName; //Handles the error in the case that the incoming directory can't be found for some reason. if (! @openDir($dir)) { echo ("<p class='body'>I'm sorry, but the image directory ".$incomingDirName." can not be found on this server.</p>"); exit(); } /* output the current directory information. testing purposes only. $thisDir=getcwd(); echo "<p class='title'>Results of getcwd(): ".$thisDir."</p><br>\n"; echo "<p class='title'>Files in ".$dir.":</p><br>\n"; */ //open up a table on the page echo(" <table align='center' border='0' cellpadding='4px'> <tr> "); //scan the directory and load its contents into an array $handle=opendir($dir); while (false !== ($file = readdir($handle))) { $retVal[] = $file; } //close the directory read operation then sort the array closedir($handle); sort($retVal); //return $retVal; //required if a Function //initialize a counter for use in formatting the table $counter = 0; //iterate over array for ($i = 0; $i < count($retVal); $i++) { //strip out the . and .. level directory information if ($retVal[$i] != "." && $retVal[$i] != "..") { //look for directory contents that start with "tn_" if (strstr($retVal[$i], "tn_")) { //if the file starts with tn_ set it for use as the img src"" $thumImg = $retVal[$i]; //then strip off the tn_ and use the result as the image to link to $linkTo = substr_replace($retVal[$i], "", 0, 3); //combine directory and file information into one variable for ease of coding $fullThumPath = $dir.$retVal[$i]; $fullLinkToPath = $dir.$linkTo; //counter starts at 0. for iterations 0-3, put images into cells in current row if ($counter <= 3) { //drop the two variables into a line to create table information echo ("<td align='center'><a href='".$fullLinkToPath."' target='_top'><img src='".$fullThumPath."' alt='Thumbnail' border='0'></a></td>"); $counter++; } //for iterations greater than 3 (four images) close the current row, start another and drop current image in first cell else { echo ("</tr><tr><td align='center'><a href='".$fullLinkToPath."' target='_top'><img src='".$fullThumPath."' alt='Thumbnail' border='0'></a></td>"); $counter = 1; } } } //This is the basis for checking for a directory without image files. It's a bit broken as it reports an error whenever a file that soesn't start with "tn_" is encountered. Which is exactly what the if() statement tells it to do. Needs a little work. /* if (! strstr($retVal[$i], "tn_")) { echo ("<p class='body'>I'm sorry, but this directory does not contain any thumbnail images. Please contact Rich and let him know he screwed up!</p>"); } */ } //ending image table tags echo(" </tr> </table> "); //ending page div tag echo(" </div> "); ?> ############################################################################ ## Rich -----Original Message----- From: markbm [mailto:[EMAIL PROTECTED]] Sent: Saturday, July 06, 2002 7:35 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] Retrieving/Displaying hyperlinked images with PHP I am trying to build a "product detail" page that pulls data from a MYSQL database using PHP. The data for the page includes product images, which I am trying to link to (i.e. from their location on the web server) instead of loading the images into the database. However, I cannot find any sample code that seems to work. Two questions: 1. Is this possible (i.e. to store the HYPERLINK to the image in the database , and as the results are returned to the product detail screen, the image file will be displayed)? OR RATHER do I need to store the physical image file in the database location and query it that way? 2. The code sample below contains several lines that show a field populated with text that I am returning....the line under the //Test comment is the field that I'm trying to pull an image back for: printf("REL_PLAN7: %s<br>\n", mysql_result($result,0,"REL_PLAN7")); printf("REL_PLAN8: %s<br>\n", mysql_result($result,0,"REL_PLAN8")); printf("REL_PLAN9: %s<br>\n", mysql_result($result,0,"REL_PLAN9")); //test printf(mysql_result($result,0,<a href="FRONT_REND">FRONT_REND</a>); NOTE: "FRONT_REND" is the name of the database field, and it contains a full web address, not relative. Any help would be GREATLY appreciated. Thanks. Mark -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php