The following code takes the values from the db and echos them inside a list. Then when the user selects a value from the list, the value must be stored to the db, but this doesn't work. Could anyone help?
Thank you in advance for your effort.
<?php
$query = "SELECT categorydescription, categoryname FROM categories ORDER BY categoryname ASC";
$result = mysql_query($query,$conn) or die('Query failed: ' . mysql_error());
?>
<select name="categoryname" id="categoryname">
<?php
while ($line = mysql_fetch_array($result, MYSQL_NUM)) {
echo "<option value= \"$line[0]\"> $line[1] </option>" ;
}
mysql_free_result($result);
$query ="INSERT INTO orderdetails (CategoryName)
VALUES('$line[0]\')"; mysql_query($query) or die(mysql_error());
?>