SHARE
TWEET

data_maandgrafiek.php

a guest Jan 10th, 2015 435 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $con = mysql_connect("localhost","p1logger","p1logger");
  3.  
  4. if (!$con) {
  5.   die('Could not connect: ' . mysql_error());
  6. }
  7.  
  8. mysql_select_db("p1", $con);
  9.  
  10. $query = mysql_query("SELECT DATE(time) as day, e_hoog, e_laag, e_totaal, verbruik_g FROM dagtotalen WHERE time BETWEEN CURDATE() - INTERVAL 2 WEEK AND CURDATE() ORDER BY day ASC");
  11.  
  12. $category = array();
  13. $category['name'] = 'day';
  14.  
  15. $series1 = array();
  16. $series1['name'] = 'Elektra hoog tarief';
  17.  
  18. $series2 = array();
  19. $series2['name'] = 'Elektra laag tarief';
  20.  
  21. $series3 = array();
  22. $series3['name'] = 'Elektra TOTAAL';
  23.  
  24. $series4 = array();
  25. $series4['name'] = 'Gas';
  26.  
  27. while($r = mysql_fetch_array($query)) {
  28.     $category['data'][] = $r['day'];
  29.     $series1['data'][] = $r['e_hoog'];
  30.     $series2['data'][] = $r['e_laag'];
  31.     $series3['data'][] = $r['e_totaal'];
  32.     $series4['data'][] = $r['verbruik_g'];
  33. }
  34.  
  35. $result = array();
  36. array_push($result,$category);
  37. array_push($result,$series1);
  38. array_push($result,$series2);
  39. array_push($result,$series3);
  40. array_push($result,$series4);
  41.  
  42. print json_encode($result, JSON_NUMERIC_CHECK);
  43.  
  44. mysql_close($con);
  45. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top