How to transfer a row from one table to another?
I have tried using the method of inserting into desired table select *
from XXX then deleting it away, but I just can't seem to insert into my
new table and delete the one in the old table.
It reads the trade_id as 1,2,3,4 but I can't seem to get it to delete.
Is there anything wrong with the query?
$query = "INSERT INTO trade_history1 (session_id,
trade_id,
selection,
date,
type,
size,
bidprice,
offerprice,
stoploss,
takeprofit,
profitandloss,
dateclose,
close)
SELECT session_id,
trade_id,
selection,
date,
type,
size,
bidprice,
offerprice,
stoploss,
takeprofit,
profitandloss,
dateclose,
close
FROM opentrades
WHERE trade_id = ?;
DELETE FROM opentrades
WHERE trade_id = ?;
COMMIT;";
$result = mysql_query($query);
if (!mysql_query($query)) {
die('Error: ' . mysql_error());//
}
mysql_close();
Important portion of code
while($row = mysql_fetch_array($result)){ //Creates a loop to loop
through results
echo "<tr><td>" . $row['trade_id'] . "</td><td>" . $row['selection'] .
"</td><td>" . $row['date'] ."</td><td>" . $row['type'] ."</td><td>" .
$row['size'] ."</td><td>" . $row['bidprice'] ."</td><td>" .
$row['offerprice'] ."</td><td>" . $row['stoploss'] ."</td><td>" .
$row['takeprofit'] ."</td><td>" . $row['profitandloss'] . "</td><td><a
href ='delete.php?id=".$row['trade_id']."'>X</a></td></tr>";
//$row['index'] the index here is a field name
}
No comments:
Post a Comment