Posted by Confused but working on it on 09/11/07 21:41
Hi all,
I'm trying to do something simple and grabbed a snippet from the php
manual for reading files in a directory. The snippet echos out a nice
list of files.
<?php
//Open images directory
$dir = opendir("images");
//List files in images directory
while (($file = readdir($dir)) !== false)
{
echo "filename: " . $file . "<br />";
}
closedir($dir);
?>
So with my very limited PHP skillset I am trying to concatente the
$file variable in an image tag. I can't seem to escape this the right
way. I've done some cutting and pasting and commenting trying to
figure this out. (keep the laughing down. :)
<?php
//NOT WORKING - shows the little blue question mark box
echo "<img src = \"/DSC01351.jpg\">";
//Works
echo "<br>";
//Open images directory
$dir = opendir("images");
//List files in images directory
while (($file = readdir($dir)) !== false)
{
// Below Works---Shows the filename like DSC01351.jpg
echo "filename: " . $file;
//NOT - shows the little blue question mark box
echo "<img src=" . $file . ">";
//NOT - shows the little blue question mark box
echo "<img src=\".$file.\">";
}
closedir($dir);
?>
Just amazingly frustrated with something that is so simple. I'v tried a
lot of ways to escape the quotes in the img tag but can't mahe it work.
left a couple of example...
Any help would be greatly appreciated.
TIA!
[Back to original message]
|