Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do i allow my rates to be refreshable?
    primarykey
    data
    text
    <p>The bid and offer is being defined by $bid,$bid1,$bid2. They need to be refreshed every 1 second and they are located in the text field which i already predefined. I am able to put the rates in upon selection but how do i actually get them refreshing?</p> <p>heres the code: </p> <p>Start.php</p> <pre><code>&lt;?php session_start(); $timestamp=time();set_time_limit (0); echo 'Welcome to trade page &lt;br&gt;'; $_SESSION['u'] = 'seyant'; $_SESSION['p'] = 'se5an123'; $_SESSION['q'] = 'eurates'; $url = "http://webrates.truefx.com/rates/connect.html?c=EUR/USD&amp;f=csv&amp;s=n"; $url1 = "http://webrates.truefx.com/rates/connect.html?c=USD/JPY&amp;f=csv&amp;s=n"; $url2 = "http://webrates.truefx.com/rates/connect.html?c=USD/CAD&amp;f=csv&amp;s=n"; $url3 = "http://webrates.truefx.com/rates/connect.html?c=EUR/JPY&amp;f=csv&amp;s=n"; $url4 = "http://webrates.truefx.com/rates/connect.html?c=EUR/CHF&amp;f=csv&amp;s=n"; $url5 = "http://webrates.truefx.com/rates/connect.html?c=GBP/USD&amp;f=csv&amp;s=n"; $url6 = "http://webrates.truefx.com/rates/connect.html?c=AUD/USD&amp;f=csv&amp;s=n"; $url7 = "http://webrates.truefx.com/rates/connect.html?c=USD/CHF&amp;f=csv&amp;s=n"; // create curl resource $ch = curl_init(); // set url curl_setopt($ch, CURLOPT_URL, $url); //return the transfer as a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // $output contains the output string $output = curl_exec($ch); // close curl resource to free up system resources curl_close($ch); $ch = curl_init(); // set url curl_setopt($ch, CURLOPT_URL, $url1); //return the transfer as a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // $output contains the output string $output1 = curl_exec($ch); // close curl resource to free up system resources curl_close($ch); $ch = curl_init(); // set url curl_setopt($ch, CURLOPT_URL, $url2); //return the transfer as a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // $output contains the output string $output2 = curl_exec($ch); // close curl resource to free up system resources curl_close($ch); $ch = curl_init(); // set url curl_setopt($ch, CURLOPT_URL, $url3); //return the transfer as a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // $output contains the output string $output3 = curl_exec($ch); // close curl resource to free up system resources curl_close($ch); $ch = curl_init(); // set url curl_setopt($ch, CURLOPT_URL, $url4); //return the transfer as a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // $output contains the output string $output4 = curl_exec($ch); // close curl resource to free up system resources curl_close($ch); $ch = curl_init(); // set url curl_setopt($ch, CURLOPT_URL, $url5); //return the transfer as a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // $output contains the output string $output5 = curl_exec($ch); // close curl resource to free up system resources curl_close($ch); $ch = curl_init(); // set url curl_setopt($ch, CURLOPT_URL, $url6); //return the transfer as a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // $output contains the output string $output6 = curl_exec($ch); // close curl resource to free up system resources curl_close($ch); $ch = curl_init(); // set url curl_setopt($ch, CURLOPT_URL, $url7); //return the transfer as a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // $output contains the output string $output7 = curl_exec($ch); // close curl resource to free up system resources curl_close($ch); // Example 1 $frag = explode(",", $output); //echo $frag[2]; //echo $frag[3]; // echo'&lt;br/&gt;'; //echo $frag[4]; //echo $frag[5]; //echo'&lt;br/&gt;'; echo'&lt;br/&gt;'; $bid = $frag[2].$frag[3]; Echo 'EUR/USD Bid '.$bid; echo'&lt;br/&gt;'; $bid1 = $frag[4].$frag[5]; Echo 'EUR/USD Offer '.$bid1; echo'&lt;br/&gt;'; $frag1 = explode(",", $output1); //echo $frag[2]; //echo $frag[3]; // echo'&lt;br/&gt;'; //echo $frag[4]; //echo $frag[5]; //echo'&lt;br/&gt;'; $bid2 = $frag1[2].$frag1[3]; Echo 'USD/JPY Bid '.$bid2;//Bid echo'&lt;br/&gt;'; $bid3 = $frag1[4].$frag1[5]; Echo 'USD/JPY Offer '.$bid3;//Offer echo'&lt;br/&gt;'; $frag2 = explode(",", $output2); //echo $frag[2]; //echo $frag[3]; // echo'&lt;br/&gt;'; //echo $frag[4]; //echo $frag[5]; //echo'&lt;br/&gt;'; $bid4 = $frag2[2].$frag2[3]; Echo 'USD/CAD Bid '.$bid4;//Bid echo'&lt;br/&gt;'; $bid5 = $frag2[4].$frag2[5]; Echo 'USD/CAD Offer '.$bid5;//Offer echo'&lt;br/&gt;'; $frag3 = explode(",", $output3); //echo $frag[2]; //echo $frag[3]; // echo'&lt;br/&gt;'; //echo $frag[4]; //echo $frag[5]; //echo'&lt;br/&gt;'; $bid6 = $frag3[2].$frag3[3]; Echo 'EUR/JPY Bid '.$bid6;//BID echo'&lt;br/&gt;'; $bid7 = $frag3[4].$frag[5]; Echo 'EUR/JPY Offer '.$bid7;//OFFER echo'&lt;br/&gt;'; $frag4 = explode(",", $output4); //echo $frag[2]; //echo $frag[3]; // echo'&lt;br/&gt;'; //echo $frag[4]; //echo $frag[5]; //echo'&lt;br/&gt;'; $bid8 = $frag4[2].$frag4[3]; Echo 'EUR/CHF Bid '.$bid8; echo'&lt;br/&gt;'; $bid9 = $frag4[4].$frag4[5]; Echo 'EUR/CHF Offer '.$bid9; echo'&lt;br/&gt;'; $frag5 = explode(",", $output5); //echo $frag[2]; //echo $frag[3]; // echo'&lt;br/&gt;'; //echo $frag[4]; //echo $frag[5]; //echo'&lt;br/&gt;'; $bid10 = $frag5[2].$frag5[3]; Echo 'GBP/USD Bid '.$bid10; echo'&lt;br/&gt;'; $bid11 = $frag5[4].$frag5[5]; Echo 'GBP/USD Offer '.$bid11; echo'&lt;br/&gt;'; $frag6 = explode(",", $output6); //echo $frag[2]; //echo $frag[3]; // echo'&lt;br/&gt;'; //echo $frag[4]; //echo $frag[5]; //echo'&lt;br/&gt;'; $bid12 = $frag6[2].$frag6[3]; Echo 'AUD/USD Bid '.$bid12; echo'&lt;br/&gt;'; $bid13 = $frag6[4].$frag6[5]; Echo 'AUD/USD Offer '.$bid13; echo'&lt;br/&gt;'; $frag7 = explode(",", $output7); //echo $frag[2]; //echo $frag[3]; // echo'&lt;br/&gt;'; //echo $frag[4]; //echo $frag[5]; //echo'&lt;br/&gt;'; $bid14 = $frag7[2].$frag7[3]; Echo 'USD/CHF Bid '.$bid14; echo'&lt;br/&gt;'; $bid15 = $frag7[4].$frag7[5]; Echo 'USD/CHF Offer '.$bid15; include 'priceadder.php'; ?&gt; &lt;html&gt; &lt;head&gt; &lt;script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt; &lt;script&gt; $(document).ready(function() { $("#bid16").load("start.php"); var refreshId = setInterval(function() { $("#bid16").load("http://webrates.truefx.com/rates/connect.html?c=EUR/USD,USD/JPY,USD/CAD,EUR/JPY,EUR/CHF,GBP/USD,AUD/USD,USD/CHF&amp;f=csv&amp;s=n"); }, 500); $.ajaxSetup({ cache: false }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="bid16"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Priceadder.php</p> <pre><code> &lt;?php $timestamp=time();set_time_limit (0); ?&gt; &lt;!DOCTYPE html&gt; &lt;head&gt;&lt;meta charset="UTF-8"&gt;&lt;/head&gt; &lt;body&gt; &lt;form action="price.php" method="get" id="myform"&gt; &lt;p&gt;Symbol : &lt;select name = "selection" id="selection"&gt; &lt;option value="Choose One"&gt;Choose One&lt;/option&gt; &lt;option value="1"&gt;EUR/USD&lt;/option&gt; &lt;option value="2"&gt;USD/JPY&lt;/option&gt; &lt;option value="3"&gt;USD/CAD&lt;/option&gt; &lt;option value="4"&gt;GBP/USD&lt;/option&gt; &lt;option value="5"&gt;EUR/JPY&lt;/option&gt; &lt;option value="6"&gt;EUR/CHF&lt;/option&gt; &lt;option value="7"&gt;AUD/USD&lt;/option&gt; &lt;option value="8"&gt;USD/CHF&lt;/option&gt; &lt;/select&gt;&lt;/p&gt; &lt;p&gt; Date : &lt;input type="datetime" value="&lt;?php echo date("Y-m-d ",$timestamp); ?&gt;" name="date"/&gt;&lt;/p&gt; &lt;p&gt; Type : &lt;input type="radio" name="type" value="buy"&gt;Buy &lt;input type="radio" name="type" value="sell"&gt;Sell &lt;p&gt; Size : &lt;input type="number"pattern="[0-9]+([\.|,][0-9]+)?" step="0.01"name="size"/&gt;&lt;/p&gt; &lt;p&gt; Bid Price : &lt;input id="bidprice" name="bidprice" type="text" value=""&gt; Offer Price&lt;input id="offerprice" name="offerprice" type="text" value=""&gt; &lt;p&gt; Stop Loss : &lt;input type="number"step="any" name="stoploss"/&gt;&lt;/p&gt; &lt;p&gt; Take Profit : &lt;input type="number"step="any"name="takeprofit"/&gt;&lt;/p&gt; &lt;input type="submit" value="Submit"/&gt; &lt;/form&gt; &lt;link rel="stylesheet" type="text/css" href=""&gt; &lt;script type="text/javascript"&gt; window.onload=function() { if (document.getElementById) { document.getElementById("selection").onchange=function() { switchme(this); } } } function switchme(SNewSel) { var ind = SNewSel.selectedIndex; var txt = document.getElementById('bidprice'); var txt2 = document.getElementById('offerprice'); switch (ind) { case 1: // car purchase txt.value = &lt;?php echo json_encode($bid); ?&gt;; txt2.value = &lt;?php echo json_encode($bid1); ?&gt;; break; case 2: // other purchase txt.value = &lt;?php echo json_encode($bid2); ?&gt;; txt2.value = &lt;?php echo json_encode($bid3); ?&gt;; break; case 3: // other purchase txt.value = &lt;?php echo json_encode($bid4); ?&gt; ; txt2.value = &lt;?php echo json_encode($bid5); ?&gt;; break; default: txt.value=''; break; } } &lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload