I've created a form to update some data in my db. I have to do is have drop-down list with all my images listed. This works. It is setup so the name of the image in the db is displayed as selected. The image is displayed below the pick list. What I would like to do is to be able to change the image displayed by selecting a new option in the pick list. THis way I can preview an image prior to inserting it into the db.
I have a javascript that will display a new image OnChange, but what's happening is that the new image is no longer displayed. When I look at the properties of the image I get the PicID, but not the PicName.
Any suggestions?
<?php
$qGetImagePicList = "SELECT PicID,PicName
FROM tblPic,tblNews
WHERE tblPic.PicID = tblNews.fk_PicID
AND PicID = '$GetNewsImage_row->PicID'";
$rGetImagePicList = mysql_query($qGetImagePicList);
while ($GetImagePicList_row = mysql_fetch_array($rGetImagePicList)) {
$PicID = $GetImagePicList_row['PicID'];
$ImageName = $GetImagePicList_row['PicName'];
$qGetPicName = "SELECT PicID,PicName
FROM tblPic";
$rGetPicName = mysql_query($qGetPicName);
echo "<select name=\"newPicName\" onChange=\"showimage()\">";
while ($GetNewPicName_row = mysql_fetch_array($rGetPicName)) {
$NewPicID = $GetNewPicName_row['PicID'];
$NewPicName = $GetNewPicName_row['PicName'];
$NewPicOption = "<option value=\"".$NewPicID."\"";
if ($NewPicID == "$PicID"){
$sel = "selected";
} else {
$sel = "";
}
$NewPicOption = $NewPicOption." $sel>$NewPicName</option>";
echo "$NewPicOption";
}
echo "</select>";
}
?>
</td>
</tr>
<tr>
<td valign="top" class="txthdr">Teaser Image</td>
<td class="intro"><img src="images/<?php echo $GetNewsImage_row->PicName; ?>" name="pictures" border="0" width="146" height="100"></td>
</tr>
<tr>
<td colspan=2><input type="Submit" name="submitok" value="Update"></td>
</tr>