Advertisement
Guest User

Untitled

a guest
May 28th, 2015
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "ticker";
  4. $password = "34a05w00";
  5. $dbname = "ticker";
  6. $query = "select id, cloakprice, btcprice, from_unixtime(timestamp, '%h:%i') as readdate from price order by id asc limit 10 ";
  7. $conn = new mysqli($servername, $username, $password, $dbname);
  8.  
  9. if ($conn->connect_error) {
  10. die("Connection failed: " . $conn->connect_error);
  11. } echo "Connected successfully";
  12.  
  13. echo ("<br>");
  14.  
  15. $result = $conn->query($query);
  16. if ($result->num_rows > 0) {
  17. $price1 = 0;
  18. $difference = 0;
  19. while($row = $result->fetch_assoc()) {
  20. echo ("<tr>");
  21. if ($price1 != 0) {
  22. $difference = round(($row["btcprice"] - $price1),2);
  23. }
  24. $price1 = $row["btcprice"];
  25.  
  26. echo ("<th class='data'>") . $row["id"]. ("</th><th class='data'>") . $row["cloakprice"]. ("</th>&nbsp <th class='data'>") . $row["btcprice"]. ("</th> <th class='data'>"). $row["readdate"]. "</th> <th class='data'> $difference </th> </tr>";
  27. // echo ("<br>");
  28. }
  29. } else {
  30. echo "0 results";
  31. }
  32. $conn->close();
  33. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement