Hi
I have the following code which i am using to populate a select box with a list of images from a directory.
I am trying to ensure that if an image is already listed in the database this option is shown, with the ability to change it to any other in the drop down box.
<select name="image">
"<option value=''>--Select One --</option>
<?php
$dirHandle=opendir('c:\\phpdev\\www\\wessextrade\\uploadimages');
while ($file = readdir($dirHandle))
{
if (stristr($file, "main"))
{
$files = str_replace("main__","",$file);
if ($files = $myrow['image'])
{
$found = "selected";
}
else
{
$found = "";
}
echo "<option value='".$files."'".$found.">".$files."</option>";
}
}
closedir($dirHandle);
?>
</select>
The problem I have is trying to get it to show which has been selected in the database.
The script currently shows me the same image name three times, rather than the three different image names in the folder.
If I remove the bits to out that put the "selected" text in, I can see all of the images, but the user does not know which is already selecetd in the database.
Hopes this makes sense.
Could someone please help?