tuxmartin

TMEP - teplomer JSON vystup

Jun 9th, 2014
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.76 KB | None | 0 0
  1. <?php
  2. require "./config.php";
  3. require "./scripts/db.php";
  4.  
  5. header('Expires: ' . gmdate('D, d M Y H:i:s') . '  GMT');
  6. header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . '  GMT');
  7. header('Content-Type: application/json; charset=utf-8');
  8. header("Cache-Control: no-store, no-cache, must-revalidate");
  9. header("Pragma: no-cache");
  10. header("Access-Control-Allow-Origin: *");
  11.  
  12. $q=mysql_query(
  13.         "SELECT teplota, vlhkost, kdy FROM tme ORDER BY id DESC LIMIT 1"
  14.         ) or die("CHYBA MySQL: " . mysql_error());
  15.  
  16. $posledni=MySQL_Fetch_Array($q);
  17.  
  18. ?>
  19. {
  20.    "teplota": <?php echo $posledni["teplota"] ?>,
  21.    "vlhkost": <?php echo ($vlhkomer == 1 ? $posledni["vlhkost"] : "null") ?>,
  22.    "cas": "<?php echo $posledni["kdy"] ?>",
  23.    "umisteni": "<?php echo $umisteni; ?>"
  24. }
Advertisement
Add Comment
Please, Sign In to add comment