I have a MySQL database with 2 tables: "providerList" and "planProfile"
I used the "providerList" table to create a dynamic <select> box in an HTML form. This is the working code (file name is plans_add.php):
<form name="add_plan" action="plans_save.php" method="post">
<SELECT NAME="select" SIZE="1">
<?
$link = mysql_connect("localhost", "root", "password") or die("Could not connect. Please try again later.");
mysql_select_db("profiles",$link) or die("Could not select database. Please try again later.");
$query = "SELECT * FROM providerList ORDER BY ProviderName";
$result = @($query);
while($line = mysql_fetch_array($result))
{
$provider = $line["ProviderName"];
$selectinfo .= "<OPTION VALUE=$provider>$provider</OPTION>";
}
print "$selectinfo";
?>
</SELECT>
</form>
When the form is submitted the selected value is not passed along to display in a confirmation page or to update the PlanProfile table. This is the code I use for the plans_save.php file(it works for all the other form fields, but not the dynamic select box):
<?
$link = mysql_connect("localhost", "root", "password") or die("Could not connect. Please try again later.");
mysql_select_db("profiles",$link) or die("Could not select database. Please try again later.");
$sql = "INSERT INTO planProfile
(ProviderName) VALUES ('$provider')";
$result = mysql_query($sql) or die("Error in query result");
// display confirmation
print "<table border=\"0\" cellspacing=\"3\">";
print "<tr><td width=\"150\"></td><td align=\"right\">Provider Name : </td><td nowrap>$provider</td></tr></table>";
// memory flush
mysql_free_result($result);
?>
What am I missing? How can I pass along the selected option to the $provider variable in the plans_save.php file?
I consider myself a layman, not a programmer. Any help is appreciated.