To all experts,
I am trying create a page that allows users to view and reuse images returned from mysql.
In the mysql database I have two columns "image_path" (which stores the path and name of an image stored in the file system) and "image_name" (a text name that the user can recognize).
The idea is to retrieve all image_path and image_name, and display the image_name (with a href), so when the user clicks on the image_name in the display, the actual image will display in another frame (THIS IS WORKING OK).
My problem is: when the image_name is clicked I also want use the image_path as a value in a form text field, to post to another page.
My code is below, but the line <input type="text" name="pick2field" id="pick2field" size="30" value="<?php echo $ipath ?>"/> is generating just one instance of the image_path, from the loop, and is not changed dynamically when the user selects a different image_name.
I have tried using javascript, additional php variables and combinations of both, but seem to be getting nowhere fast.
Any suggestions would be warmly welcomed.
<?
$i=0;
while ($i < $num) {
$ipath = mysql_result($result, $i, "image_path");
$iname = mysql_result($result, $i, "image_name");
$target ="picframe";
echo "<P><a href=".$ipath." target=".$target.">".$iname."</a>";
$i++;
}
?>
</td>
<td width="50%"><iframe src="../blank.htm" name="picframe" scrolling="auto" height="175" width="100%" align="top" frameborder="0"></iframe></td>
</tr>
<tr>
<td colspan="2">
<form name="form1" method="post" action="">
<div align="center">
<label>
<input type="text" name="pick2field" id="pick2field" size="30" value="<?php echo $ipath ?>"/>
</label>
</div>
</form>
</td>
</tr>