Bitcoin Forum
July 05, 2024, 10:33:32 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoin Price Widget Where I was wrong?  (Read 189 times)
nahmank (OP)
Newbie
*
Offline Offline

Activity: 9
Merit: 0


View Profile
October 18, 2017, 07:04:25 AM
 #1

https://ibb.co/fnUOD6

data.php
Code:
<?php

$url 
"https://www.bitstamp.net/api/ticker/";
$fgc file_get_contents($url);
$json json_decode($fgctrue);

$price $json["last"];
$price number_format($price2);
$high $json["high"];
$low $json["low"];
$date date("m-d-Y - h:i:sa");
$open $json["open"];

if(
$open $price){
//price went up
$indicator "+";
$change $price $open;
$percent $change $open;
$percent $percent 100;
$percentChange $indicator.number_format(percent2);
$color "green";
}
if(
$open $price){
//price went down
$indicator "-";
$change $open $price;
$percent $change $open;
$percent $percent 100;
$percentChange $indicator.number_format(percent2);
$color "red";
}

$table = <<<EOT
<table width="100%">
<tr>
<td rowspan="3" width="60%" id="lastPrice">$
$price</td>
<td align="right" style="color: 
$color;">$percentChange%</td>
</tr>
<tr>
<td align="right">$
$high</td>
</tr>
<tr>
<td align="right">$
$low</td>
</tr>
<tr>
<td colspan="2" align="right" id="timeDate">
$date</td>
</tr>
</table>
EOT;

echo 
$table;
?>

price.html
Code:
<!DOCTYPE html>
<html>
<head>
<title>Price Widget</title>
<style>
#container{
width: 270px;
height: 90px;
border: 1px solid #000;
background-color: #2f2f2f;
overflow: hidden;
border-radius: 3px;
color: #fefdfb;
}
#lastPrice{
font-size: 30px;
}
#timeDate{
color: #999;
font-size: 9px
}
</style>
<script src="//code.jquery.com/jquery-1.12.0.min.js"></script>
</head>
<body>
<div id="container">
</div>
<script>
$('document').ready(function (){
refreshData();
}
);

function refreshData(){
$('#container').load("data.php", function(){
setTimeout(refreshData, 15000);
});
};
</script>
</body>
</html>

Where I was wrong?
thank you
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!