I am a beginner. I have a dropdown that is populated from a query from my db. I would like for the user to select something from the drop down, click submit and have this update a table. I have been able to find out how to update a table with the submit button if using text boxes, but not from a drop down. Here is what I have right now. I would like to send 'userID' (which is found based on the user logged in ->($query_row[userID])) and 'ingredientID' to the table 'useringredient'. I would assume I'd need an "insert.php" that would be part of this, but I don't know where to start with the form at. Any help would be appreciated. Thanks
<?php
// Connect to mysql
mysql_connect("*", "*", "*") or die(mysql_error());
mysql_select_db("*") or die(mysql_error());
// check cookies to make sure they are logged in
if(isset($_COOKIE['ID_my_site']))
{
$username = $_COOKIE['ID_my_site'];
$pass = $_COOKIE['Key_my_site'];
$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());
$query = mysql_query("SELECT userID FROM users WHERE username = '$username'");
$query_row = mysql_fetch_array($query);
while($info = mysql_fetch_array( $check ))
{
// if the cookie has the wrong password, they are taken to the login page
if ($pass != $info['password'])
{ header("Location: login.php");
}
// otherwise they are shown the member area
else
{
// to make sure info is being pulled correctly
echo "Welcome $username<p>";
echo($query_row[userID]);
// this is pulling the ingredients from db
$result = @mysql_query("SELECT ingredientID,ingredient FROM ingredients");
// this is putting the ingredients into a dropdown
print "<p>Select ingredient(s):\n";
print "<select name=\"ingredient\">\n";
while ($row = mysql_fetch_assoc($result)){
$ingredientID = $row['ingredientID'];
$ingredient = $row['ingredient'];
print "<option value=$ingredientID>$ingredient</option>\n";
}
print "</select>\n";
print "</p>\n";
// link for drinklist
echo "<a href=drinklist.php>View Current List</a>";
print "</p>\n";
// logout
echo "<a href=logout.php>Logout</a>";
}
}
}
else
//if the cookie does not exist, they are taken to the login screen
{
header("Location: login.php");
}
?>