Advertisement
Guest User

Untitled

a guest
Jul 18th, 2013
665
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. <?php
  2. $con = mysql_connect("localhost","root","");
  3.  
  4. if (!$con) {
  5.   die('Could not connect: ' . mysql_error());
  6. }
  7.  
  8. mysql_select_db("mqtt", $con);
  9.  
  10. $return_arr = array();
  11.  
  12. $fetch = mysql_query("SELECT timeof, message FROM temperatures WHERE DATE(timeof) BETWEEN DATE_SUB(CURDATE(), INTERVAL 7 DAY) AND CURDATE() AND locationmap = 'master'");
  13. $i=0;
  14. while ($row = mysql_fetch_array($fetch, MYSQL_ASSOC)) {
  15.     $rows[$i]=array(strtotime($row[timeof])*1000 ,(float)$row[message]);
  16.     $i++;
  17. }
  18.  
  19. echo json_encode($rows);
  20.  
  21. mysql_close($con);
  22. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement