https://ibb.co/fnUOD6data.php
<?php
$url = "https://www.bitstamp.net/api/ticker/";
$fgc = file_get_contents($url);
$json = json_decode($fgc, true);
$price = $json["last"];
$price = number_format($price, 2);
$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(percent, 2);
$color = "green";
}
if($open > $price){
//price went down
$indicator = "-";
$change = $open - $price;
$percent = $change / $open;
$percent = $percent * 100;
$percentChange = $indicator.number_format(percent, 2);
$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
<!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