data.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 = <<
$$price | $color;">$percentChange% |
$$high | |
$$low | |
$date |
EOT;
echo $table;
?>
price.html
Where I was wrong?
thank you