代码只是继续检索要插入数据库的最后一行。 (下图)我选择并删除了USD
和CA
,当插入数据库时,行中的损益和当前价格不匹配。
当它应该是1.04930和-0.72时,它显示为98.570和1.17。
问题是它一直在while循环中获取最后一行值并插入到DB中。我如何解决这个问题,以便变量从右侧行检索?
while echo for echo
while($row = mysql_fetch_assoc($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>" . $closedb .
"</td><td>" . $profitandloss .
"</td><td><a href ='delete.php?id=".
$row['trade_id']."'>X</a>
</td></tr>";
}
function callvariable($closedb,$profitandloss)
{
$variable=array('$closedb','$profitandloss');
return $variable;
}
SQL
$var=callvariable($closedb,$profitandloss);
$mysqli-> query("UPDATE `trade_history1` SET `dateclose` = CURRENT_TIMESTAMP,
`close` = '{$closedb}',
`profitandloss` = '{$profitandloss}'
WHERE `trade_id`= ".$trade_id);