Welcome to WebmasterWorld Guest from 22.214.171.124
Can anyone please tell me the correct syntax to use for assigning the selected option from a pick-list before inserting to a mysql database?
I am trying to give the visitor the option of some 20-30 categories from a pick-list and then I want to store the selected category in a field (called 'cat') in my mysql table.
Not having a lot of luck!
<form action="process.php" method="POST">
// do your database connection
$query="INSERT INTO mytable (cat) VALUES ('".$_POST['cat']."')";
print("your wish is my command");
Thanks for the code.
Since posting I did get it to work using a rather strange -
echo "<option value=bus"; if ($r->category == 'bus') echo " SELECTED"; echo ">Business</option>";
Yours looks far simpler, less coding and neater.
...and point taken : pick-list==select box!