Hi I am very new to php and mysql, so I'm sorry if I sound incredibly thick!
I am trying to assign the selected value from a list box to a variable, so that I can retrieve the related value from a database using another query statement. I have populated a list box with stock codes, so that the user can select one. When this is selected, I would like the related stock description to appear in an adjacent text box, or something similar.
This is the code I have used so far for the list box:
<?php
$link = mysql_connect("localhost", "root");
mysql_select_db("invoice");
echo "<table border=0 width=50% align=center cellpadding=2>
<TR>\n
<TD align=center><B>Stock Code</B></TD>";
echo "<TD> <SELECT name=item>";
$query = "SELECT stockcode FROM stockitem";
$result = mysql_query($query);
while ($line = mysql_fetch_array($result))
{
foreach ($line as $value)
{
print "<OPTION value='$value'";
}
print ">$value</OPTION>";
} "</TD> </TR>";
mysql_close($link);
print "</SELECT>";
echo "</table>";
?>
Thanks for any help you can offer.
😕