Hello,
This is what I am trying to accomplish: A user goes to a page that has a drop down menu containing a variable (currently there are two dropdown menus, but it doesn't apply here). When the small form is executed, another will show. "company_name" will than be entered and the next small form will be executed updating the dataabase. The problem I am having is this: the variable "record_id" is lost after the first form is executed. I need it to stay so that the update query can read it and use it. Thanks.
Jeff
print "
<form action=\"$PHP_SELF\" method=\"POST\">
<select name=\"record_id\">
<option value=\"MSFT\">MSFT</option>
</select>
<select name=\"select_record\">
<option name=\"general\">General</option>
<option name=\"day1\">Monday (Day1)</option>
<option name=\"day2\">Tuesday (Day2)</option>
</select>
<input type=\"submit\" name=\"show\" value=\"show\" class=\"pushbutton\">
</form>";
if ( $record_id )
{
if ( $_POST['update'] == "Update" )
{
update_record();
}
else
{
update_form();
}
}
function update_form()
{
print"
<form action=\"$PHP_SELF\" method=\"POST\">
Company Name<input type=\"text\" name=\"company_name\"><br>
<input type=\"submit\" name=\"update\" value=\"Update\" class=\"pushbutton\">
</form>";
}
function update_record()
{
global $company_name;
global $record_id;
$query = mysql_query( "UPDATE market_research SET company_name = '$company_name' WHERE symbol = '$record_id'" );
if ( $query )
{
print "You Have Successfully Updated The Record: $record_id";
}
else
{
print "ERROR";
}
}