Hello,
This is what I'm trying to accomplish:
You select the record id and the record inforamtion you want to view. Than an update form is shown with the currently stored information all ready in the fields.
The problem I am having is when updating the table, there is added text.
To view the problem, please visit: http://rushhourdirect.com/market_research/update_record.php - select MSFT and Entry 1 (Monday). Input a number (no more than 5 digits) and repeat this. You'll see that there are added values like "=" or your inputted data will be repeated.
Here is the code:
print "
<form action=\"$PHP_SELF\" method=\"POST\">
<select name=\"record_id\">
<option>Select Record</option>";
$query_select_recordid = mysql_query( "SELECT symbol FROM market_research" );
while ( $a_row = mysql_fetch_array( $query_select_recordid ) )
{
print "<option value=\"$a_row[symbol]\">$a_row[symbol]</option>";
}
print "
</select>
<select name=\"select_record\">
<option>- - - - Select Data - - - -</option>
<option value=\"general\">General Data</option>
<option value=\"entry1\">Entry 1 (Monday)</option>
<option value=\"entry2\">Entry 2 (Tuesday)</option>
<option value=\"entry3\">Entry 3 (Wednesday)</option>
<option value=\"entry4\">Entry 4 (Thursday)</option>
<option value=\"entry5\">Entry 5 (Friday)</option>
</select>
<input type=\"submit\" value=\"Show Data\" class=\"pushbutton\">
</form>";
if ( isset($record_id) and $record_id != Select)
{
if ( isset($company_name) )
{
update_general_data();
}
elseif ( isset($entry1_open) )
{
update_entry1_data();
}
else
{
switch ( $select_record )
{
case "entry1":
update_entry1_form();
break;
default:
print "Please Select Record Info";
}
}
}
//FUNCTIONS - UPDATE FORMS
function update_entry1_form()
{
global $record_id;
$query_select = mysql_query( "SELECT * FROM market_research WHERE symbol = '$record_id'" );
if ( $as_row = mysql_fetch_array( $query_select ) )
{
print "
You are updating: $record_id
<form action=\"$PHP_SELF\" method=\"POST\">
<input type=\"hidden\" name=\"record_id\" value=\"$record_id\">
Open<input type=\"text\" name=\"entry1_open\" value=\"$as_row[entry1_open]\"><br>
Close<input type=\"text\" name=\"entry1_close\" value=\"$as_row[entry1_close]\"><br>
High<input type=\"text\" name=\"entry1_high\" value=\"$as_row[entry1_high]\"><br>
Low<input type=\"text\" name=\"entry1_low\" value=\"$as_row[entry1_low]\"><br>
Volume<input type=\"text\" name=\"entry1_volume\" value=\"$as_row[entry1_volume]\"><br>
Bid<input type=\"text\" name=\"entry1_bid\" value=\"$as_row[entry1_bid]\"><br>
Ask<input type=\"text\" name=\"entry1_ask\" value=\"$as_row[entry1_ask]\"><br>
Change($)<input type=\"text\" name=\"entry1_change_d\" value=\"$as_row[entry1_change_d]\"><br>
Change(%)<input type=\"text\" name=\"entry1_change_p\" value=\"$as_row[entry1_change_p]\"><br>
Transaction<input type=\"text\" name=\"entry1_transaction\" value=\"$as_row[entry1_transaction]\"><br>
<input type=\"submit\" value=\"Update Data\" class=\"pushbutton\">
</form>";
}
}
//FUNCTIONS - UPDATE RECORD QUERIES
function update_entry1_data()
{
global $entry1_open, $entry1_close, $entry1_high, $entry1_low, $entry1_volume, $entry1_ask, $entry1_bid, $entry1_change_d, $entry1_change_p, $entry1_transaction, $record_id;
$query = mysql_query( "UPDATE market_research SET entry1_open = '$entry1_open = $_POST[entry1_open];', entry1_close = '$entry1_close = $_POST[entry1_close];', entry1_high = '$entry1_high = $_POST[entry1_high];', entry1_low = '$entry1_low = $_POST[entry1_low];', entry1_volume = '$entry1_volume = $_POST[entry1_volume];', entry1_bid = '$entry1_bid = $_POST[entry1_bid];', entry1_ask = '$entry1_ask = $_POST[entry1_ask];', entry1_change_d = '$entry1_change_d = $_POST[entry1_change_d];', entry1_change_p = '$entry1_change_p = $_POST[entry1_change_p];', entry1_transaction = '$entry1_transaction = $_POST[entry1_transaction];' WHERE symbol = '$record_id' " );
if ( $query )
{
print "The Record <b>$record_id</b> has been successfully updated.";
}
}
mysql_close( $link );
P.S. - Sorry for the messy code and thanks for the help!