我试图刷新一个表,因为变量在不断更新,我想每隔几秒重新更新一次这些变量.我已经通过给表创建一个id并为它创建一个div来完成代码.代码将解释我的实际情况.提前致谢 !编辑:添加了Var Table和Var Refresher.但是代码仍然不会重新加载我的表!任何想法?
test.php的
var table = $('#tableID');
// refresh every 5 seconds
var refresher = setInterval(function() {
table.load("1103242B/processing/js.php");
}, 5000);
setTimeout(function() {
clearTimeout(refresher);
}, 1800000);
JS.php
require_once 'connect.php';
include 'start.php';
include 'functions.php';
header("Cache-Control: no-cache,no-store");
$query = "SELECT * FROM opentrades"; //You don't need a ; like you do in SQL
$result = mysql_query($query);
echo "
echo "
" . "Order Number" . "" . "Selection" . "" . "Date" . "" . "Type" . "" . "Size" . "" . "Bid Price" . "" . "Offer Price" . "" ."Stop Loss" . "" . "Take Profit" . "" ."Profit/Loss(USD)"."" ."Close"."" ; //$row['index'] the index here is a field namewhile($row = mysql_fetch_assoc($result)){ //Creates a loop to loop through results
if ($row['selection']=='eur/usd')// TO RETRIEVE BID AND OFFER FOR EACH ROW
{
$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;
}
if ($row['type']=="buy")
{
$minipipskiller='10';
$offeropen=$row['offerprice'];
$pips=$offerpricepl-$offeropen;
$closedb=$offeropen;
$pips1=round($pips, 6);
$pips2 = str_replace('.', '', $pips1);
if ($pips2<0)
{
$pips2 = str_replace('-', '', $pips2);
$pips2 = ltrim($pips2, '0');
$pips2 = -1 * abs($pips2);
}
else {
$pips2 = ltrim($pips2, '0');
}
$pips3=$pips2/$minipipskiller;
}// PIP COUNTING
elseif ($row['type']=="sell")//FOR PIP COUNTING
{
$minipipskiller='10';
$bidopen=$row['bidprice'];
$pips=$bidopen-$bidpricepl;
$closedb=$bidopen;
$pips1=round($pips, 6);
$pips2 = str_replace('.', '', $pips1);
if ($pips2<0)
{
$pips2 = str_replace('-', '', $pips2);
$pips2 = ltrim($pips2, '0');
$pips2 = -1 * abs($pips2);
}
else {
$pips2 = ltrim($pips2, '0');
}
$pips3=$pips2/$minipipskiller;
}
$ticksize= "0.0001";// FOR PROFIT AND LOSS
$lot1 = "100000";
$sizecalc=$row['size'] * $lot1;
if ($row['type']=="buy")
{
$profitandloss=$sizecalc*$ticksize*$pips3; //per TRADE
}
if ($row['type']=="sell")
{
$profitandloss=$sizecalc*$ticksize*$pips3; //per TRADE
}
$zero= '0';
if($profitandloss
$profitText = "
} elseif ($profitandloss>$zero) {
$profitText = "
}
$sum+= $profitandloss;
echo "
" . $row['trade_id'] ."
" . $row['selection'] ."
" . $row['date'] ."
" . $row['type'] ."
" . $row['size'] ."
" . $row['bidprice'] ."
" . $row['offerprice'] ."
" . $row['stoploss'] ."
" . $row['takeprofit'] ."
" . $profitText ."
X";$profitandloss=0;
if($sum
$sumText = "
} elseif ($sum>$zero) {
$sumText = "
}
}
echo "
";
?>