0
我想檢索數據,只是把它放到我的數據庫中。 $ bid,$ bid1,$ bid2,bidpricepl,offerpricepl已被定義。除此之外,所有的行數據都是從db中撤銷的,有一行,盈虧是一個變量。 Foreach行,這個變量的值被壓下一個檔位,意味着放置2,該值是放置位置1.我附上了一張圖片,以便大家理解。我的查詢有什麼問題? EG表缺少我的第一行檢索數據庫
ORDERNUMBER:損益表:
sadasdasd BLANK
sadasdasd 1
sadasdasd 2
sadasdasd 3
查詢調用和顯示
$query = "SELECT * FROM opentrades"; //You don't need a ; like you do in SQL
$result = mysql_query($query);
echo "<table border = '1px'>"; // start a table tag in the HTML
echo "<tr><td>" . "Order Number" . "</td><td>" . "Selection" . "</td><td>" . "Date" . "</td><td>" . "Type" . "</td><td>" . "Size" . "</td><td>" . "Bid Price" . "</td><td>" . "Offer Price" . "</td><td>" ."Stop Loss" . "</td><td>" . "Take Profit" . "</td><td>" ."Profit/Loss"."</td><td>" ."Close"."</td></tr>" ; //$row['index'] the index here is a field name
while($row = mysql_fetch_array($result,MYSQLI_BOTH)){ //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>" . $bidpricepl . "</td><td><a href ='delete.php?id=".$row['trade_id']."'>X</a></td></tr>";
if ($row['selection']=='eur/usd')
{
$bidpricepl=$bid;
$offerpricepl=$bid1;
}
elseif ($row['selection']=='usd/jpy')
{
$bidpricepl=$bid2;
$offerpricepl=$bid3;
}
elseif ($row['selection']=='usd/cad')
{
$bidpricepl=$bid4;
$offerpricepl=$bid5;
}
elseif ($row['selection']=='eur/jpy')
{
$bidpricepl=$bid6;
$offerpricepl=$bid7;
}
elseif ($row['selection']=='eur/chf')
{
$bidpricepl=$bid8;
$offerpricepl=$bid9;
}
elseif ($row['selection']=='gbp/usd')
{
$bidpricepl=$bid10;
$offerpricepl=$bid11;
}
elseif ($row['selection']=='aud/usd')
{
$bidpricepl=$bid12;
$offerpricepl=$bid13;
}
elseif ($row['selection']=='usd/chf')
{
$bidpricepl=$bid14;
$offerpricepl=$bid15;
}
}
echo "</table><br>";
YUP THANKS FOR ANSWER – nigel