I'm very sorry that there is so much to look through, but I couldn't isolate the problem area.
My problem is: The information printed to the function: "update_fundamental_data" is contained in the variable $form_body_fundamental_data, and in there is a select query, selecting information from a database to display in text fields (that are also variables for the update function used after the form is submitted). The information in the database is not shown in the text fields *the select statement does not work - i beleive it has something to do with the varibles inside another variable.
Please help, if you have any questions, please respond back to me.
If you'd like to see the script working, please visit http://rushhourdirect.com/market_research/update_record.php and select US:MSFT with Fundamental Data - you will notice that nothing shows up into the datafields.
P.S. I apologize for the size of the data to look through, I greatly appreciate your help. Thanks!
<?php
$pagename = "Update Record";
$form_header = " $table_name for $record_id";
$form_sub_header = "
The following table shows the $table_name currently listed in the $record_id record. To update, or make changes to $record_id, edit the current data listed within the text fields, then hit "Update Record"";
$successful_update = "
<table cellSpacing=\"0\" cellPadding=\"1\" width=\"100%\">
<tr>
<th class=\"smallfontreverse\" noWrap align=\"center\" colSpan=\"7\" height=\"18\"> The $table_name for $record_id has been successfully updated.</th>
</tr>
</table>
<br>";
$form_body_fundamental_data = "
<form action=\"$PHP_SELF\" method=\"POST\">
<input type=\"hidden\" name=\"record_id\" value=\"$record_id\">
<input type=\"hidden\" name=\"table_name\" value=\"$table_name\">
<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">
<tr>
<th align=\"right\"> </th>
<th class=\"smallfontreverse\" align=\"left\" valign=\"bottom\" colspan=\"7\">$form_header</th>
</tr>
<tr bgcolor=\"#cccccc\">
<td align=\"right\"> </td>
<td class=\"smallprompt\">$form_sub_header</td>
<td align=\"right\"> </td>
</tr>
</table>
<table width=\"100%\" border=\"1\" cellpadding=\"1\" cellspacing=\"0\" rules=\"rows\"
frame=\"below\" bordercolor=\"#cccccc\" bordercolordark=\"white\">
<tr>
<td colspan=\"7\"><br>
</td>
</tr>
<tr>
<td align=\"right\"> </td>
<td>*</td>
<td align=\"left\">Company Name:</td>
<td align=\"right\"><input type=\"text\" size=\"25\" name=\"company_name\"
value=\"$as_row[company_name]\"></td>
</tr>
<tr>
<td align=\"right\"> </td>
<td>*</td>
<td align=\"left\">Symbol:</td>
<td align=\"right\"><input type=\"text\" size=\"6\" name=\"symbol\"
value=\"$as_row[symbol]\"></td>
</tr>
<tr>
<td align=\"right\"> </td>
<td>*</td>
<td align=\"left\">Exchange:</td>
<td class=\"smallprompt\" align=\"right\">(Currently: $as_row[exchange])
<select name=\"exchange\">
<option>Select</option>
<option>AMEX</option>
<option>NASDAQ</option>
<option>NYSE</option>
<option>TSE</option>
</select></td>
</tr>
<tr>
<td align=\"right\"> </td>
<td> </td>
<td align=\"left\">Market Capitalization:</td>
<td align=\"right\"><input type=\"text\" size=\"7\" name=\"market_cap\"
value=\"$as_row[market_cap]\"></td>
</tr>
<tr>
<td align=\"right\"> </td>
<td> </td>
<td align=\"left\">Number of Shares Out:</td>
<td align=\"right\"><input type=\"text\" size=\"7\" name=\"no_shares_out\"
value=\"$as_row[no_shares_out]\"></td>
</tr>
<tr>
<td align=\"right\"> </td>
<td> </td>
<td align=\"left\">52 Week High:</td>
<td align=\"right\">$ <input type=\"text\" size=\"5\" name=\"_52wk_high\"
value=\"$as_row[_52wk_high]\"></td>
</tr>
<tr>
<td align=\"right\"> </td>
<td> </td>
<td align=\"left\">52 Week Low:</td>
<td align=\"right\">$ <input type=\"text\" size=\"5\" name=\"_52wk_low\"
value=\"$as_row[_52wk_low]\"></td>
</tr>
<tr>
<td align=\"right\" colspan=\"7\" bordercolor=\"#ffffff\"><br>
<input type=\"submit\" value=\"Update Record\" class=\"pushbutton\"></td>
</tr>
</table>
</form>";
$user = "rhd";
$pass = "rhd_0914";
$db = "rushhourdirect_com";
$link = mysql_connect( "localhost", $user, $pass );
if ( ! $link )
die( "Couldn't connect to MySQL" );
mysql_select_db( $db, $link )
or die ( "Couldn't open $db: ".mysql_error() );
include "page_top.php";
print "
<form action=\"$PHP_SELF\" method=\"POST\">
<table border=\"0\" cellpadding=\"1\" cellspacing=\"0\" align=\"center\" width=\"100%\">
<tr>
<td colspan=\"2\"></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td valign=\"top\">
<table width=\"100%\" cellpadding=\"1\" cellspacing=\"0\">
<tr>
<th align=\"right\"> </th>
<th class=\"smallfontreverse\"align=\"left\" valign=\"bottom\" colspan=\"7\"><b>Select Record To Update</b></th>
</tr>
<tr bgcolor=\"#cccccc\">
<td align=\"right\"> </td>
<td class=\"smallprompt\">To update/edit a record, first select the Record's ID by selecting the corresponding Symbol (Ex: MSFT). Than select the attributes of the record you would like to change and click Show Data.</td>
<td align=\"right\"> </td>
</tr>
</table>
<table width=\"100%\" border=\"1\" cellpadding=\"1\" cellspacing=\"0\" rules=\"rows\"
frame=\"below\" bordercolor=\"#cccccc\" bordercolordark=\"white\">
<tr>
<td colspan=\"7\"><br></td>
</tr>
<tr>
<td align=\"right\"> </td>
<td align=\"left\">Record ID:</td>
<td align=\"right\">
<select name=\"record_id\">
<option>Select</option>";
$query_select_record_id = mysql_query( "SELECT symbol FROM ingent_fundamental_data" );
while ( $a_row = mysql_fetch_array( $query_select_record_id ) )
{
print "<option value=\"$a_row[symbol]\">$a_row[symbol]</option>";
}
print "
</select></td>
<td width=\"20\" rowSpan=\"2\"> </td>
<td rowspan=\"2\" align=\"right\"><input type=\"submit\" value=\"Show Data\" class=\"pushbutton\"></td>
</tr>
<tr>
<td align=\"right\"> </td>
<td align=\"left\">Data:</td>
<td align=\"right\">
<select name=\"table_name\">
<option>Select Data</option>
<option value=\"Fundamental Data\">Fundamental Data</option>
<option value=\"Data Entry 1\">Data Entry 1 (Monday)</option>
<option value=\"Data Entry 2\">Data Entry 2 (Tuesday)</option>
<option value=\"Data Entry 3\">Data Entry 3 (Wednesday)</option>
<option value=\"Data Entry 4\">Data Entry 4 (Thursday)</option>
<option value=\"Data Entry 5\">Data Entry 5 (Friday)</option>
</select></td>
</tr>
<tr>
<td colspan=\"7\" bordercolor=\"#ffffff\"></td>
</tr>
</table>
</td>
</tr>
</table>
</form>";
// PAGE FLOW - Page Structure - START
if ( isset($record_id) and $record_id != Select)
{
if ( isset($company_name) )
{
update_fundamental_data();
}
else
{
switch ( $table_name )
{
case "Fundamental Data":
update_fundamental_data_form();
break;
default:
print "ERROR MESSAGE HERE";
}
}
}
// PAGE FLOW - Page Structure - END
// FUNCTIONS - MySQL Select Queries + Update Forms - START
function update_fundamental_data_form()
{
global $form_body_fundamental_data, $record_id, $table_name, $form_header, $form_sub_header;
$query_select = mysql_query( "SELECT * FROM ingent_fundamental_data WHERE symbol = '$record_id'" );
if ( $as_row = mysql_fetch_array( $query_select ) )
{
print "$form_body_fundamental_data";
$company_name = $_POST["company_name"];
$symbol = $_POST["symbol"];
$exchange = $_POST["exchange"];
$market_cap = $_POST["market_cap"];
$no_shares_out = $_POST["no_shares_out"];
$inst_ownership = $_POST["inst_ownership"];
$_52wk_high = $_POST["_52wk_high"];
$_52wk_low = $_POST["_52wk_low"];
}
}
// FUNCTIONS - MySQL Select Queries + Update Forms - END
// FUNCTIONS - MySQL Update Queries - START
function update_fundamental_data()
{
global $company_name, $symbol, $exchange, $market_cap, $no_shares_out, $_52wk_high, $_52wk_low, $record_id, $successful_update;
$query = mysql_query( "UPDATE ingent_fundamental_data SET company_name = '$company_name', symbol = '$symbol', exchange = '$exchange', market_cap = '$market_cap', no_shares_out = '$no_shares_out', _52wk_high = '$_52wk_high', _52wk_low = '$_52wk_low' WHERE symbol = '$record_id'" );
if ( $query )
{
print "$successful_update";
}
}
// FUNCTIONS - MySQL Update Queries - END
mysql_close( $link );
include "page_bottom.php";
?>