Ok, I was trying to keep it simple :), but here goes: In essence the problem is that (at the end of the script) income_out is coming out as just $option_close_price and not the intended $option_close_price*$no_sold, and profit_loss is coming out as just -$option_close_price and not the intended $income_in-$option_close_price*$no_sold. Justin <form action="<? echo $PHP_SELF ?>" method="post"> <?php mysql_pconnect("localhost","root","password"); mysql_select_db("options"); $result = mysql_query("select * from open_trades"); print "<table border=\"1\" cellpadding=\"3\" cellspacing=\"0\">\n"; print "<tr><td></td><td>ID</td><td>Open Date</td><td>Share</td><td>Code</td><td>Short or<br> Long Trade</td><td>Expiry</td><td>Excercise</td><td>Option Price</td><td>Number<br> Purchased</td><td>Number Sold</td><td>Income In</td><td>Income Out</td><td></tr>"; while ($row = mysql_fetch_array($result)) { print "<tr><td>"; print "<INPUT TYPE='RADIO' NAME='id' VALUE='".$row["id"]."'>"; print "</td><td>"; print $row["id"]; print "</td><td>"; print $row["open_date"]; print "</td><td>"; print $row["share"]; print "</td><td>"; print $row["code"]; print "</td><td>"; print $row["short_long_trade"]; print "</td><td>"; print $row["expiry"]; print "</td><td>"; print $row["excercise"]; print "</td><td>"; print $row["option_price"]; print "</td><td>"; print $row["no_purchased"]; print "</td><td>"; print $row["no_sold"]; print "</td><td>"; print $row["income_in"]; print "</td><td>"; print $row["income_out"]; print "</td></tr>\n"; } print "</table>\n"; ?> <input type="submit" name="submit" value="Select"> </form> <?php if($submit) { $query = "CREATE TABLE media SELECT * FROM open_trades WHERE id = $id"; $result = mysql_query($query); $query = "ALTER TABLE media ADD closed_date VARCHAR(10) AFTER open_date"; $result = mysql_query($query); $query = "ALTER TABLE media ADD profit_loss DECIMAL(10,2) AFTER income_out"; $result = mysql_query($query); $query = "ALTER TABLE media ADD notes VARCHAR(255) AFTER profit_loss"; $result = mysql_query($query); $query = "ALTER TABLE media ADD option_close_price DECIMAL(10,2)"; $result = mysql_query($query); ?> Please enter closing details; <?php if($short_long_trade="Short") { ?> <form action="updated1.php" method="post"> <table border="1" width="40%"> <tr> <td width="30%">Closed Date:</td> <td width="70%" align="center"><input type="Text" name="closed_date"></td> </tr> <tr> <td width="30%">Option Close Price</td> <td width="70%" align="center"><input type="Text" name="option_close_price"><br></td> </tr> <tr> <td width="30%">Notes</td> <td width="70%" align="center"><textarea name="notes" rows="3" cols="20"></textarea><br></td> </tr> <td align="center"> <input type="submit" name="update" value="Update"> </td> </form> <? } ---this is updated1.php--------which is called by the above if statement <?php if($update) { mysql_pconnect("localhost","root","password"); mysql_select_db("options"); $query = "UPDATE media SET closed_date='$closed_date', notes='$notes', option_close_price='$option_close_price'"; $result = mysql_query($query); $query = "SELECT * FROM media"; $result = mysql_query($query); $query = "UPDATE media SET income_out='$option_close_price*$no_sold', profit_loss='$income_in-$option_close_price*$no_sold'"; $result = mysql_query($query); $query = "INSERT INTO closed_trades SELECT * FROM media"; $result = mysql_query($query); $query = "DROP TABLE media"; $result = mysql_query($query); echo "Trade Closed"; } ?> -----Original Message----- From: Sam Chill [mailto:samchill@xxxxxxxxx] Sent: Thursday, 24 June 2004 3:25 PM To: php-db@xxxxxxxxxxxxx Subject: Re: Update data problem Justin, Is the code you posted all of the code or just a small snippet? You don't appear to be setting $C or $G. Could you post a larger code dump please? -Sam -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php