Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <table width="100%">
- <tr><td width='20%'> </td><td width='60%'>
- <table width='100%' border='1' bgcolor='#ffffff' style='border:1 px solid black; border-collapse: collapse;'>
- <tr align='center'><td colspan='6' style='font-size:225%; color:#000000';>Log - only showing the last 20 entries</td></tr>
- <tr><td class='tabelTitel' align="center">
- <?php
- require_once '-----------link to connection file-------------';
- connect();
- $result = mysql_query("SELECT * FROM LDR ORDER BY LDR.id DESC LIMIT 20");
- if ($result) {
- $labels = array();
- $temp = array();
- $pir = array();
- $hum = array();
- while ($row = mysql_fetch_assoc($result)) {
- $labels[] = gmdate("Y-m-d\ T H:i:s \Z",$row['dtg']);
- $temp[] = $row["temp"];
- $pir[] = $row["pir"];
- $hum[] = $row["hum"];
- }
- // Now you can aggregate all the data into one string
- $temp_string = "[" . join(", ", $temp) . "]";
- $labels_string = "['" . join("', '", $labels) . "']";
- $pir_string = "['" . join("', '", $pir) . "']";
- $hum_string = "['" . join("', '", $hum) . "']";
- } else {
- print('MySQL query failed with error: ' . mysql_error());
- }
- ?>
- <script>
- window.onload = function ()
- {
- var line = new RGraph.Line({
- id: 'cvs',
- data: [
- <?php print($temp_string) ?>,
- <?php print($pir_string) ?>,
- <?php print($hum_string) ?>
- ],
- options: {
- spline: true,
- splineTickmarksFill: null,
- splineTickmarksSize: 5,
- splineTickmarksStroke: '#aaa',
- splineTickmarksLinewidth: 2,
- linewidth: 3,
- hmargin: 20,
- labels: <?php print($labels_string) ?>,
- tooltips: <?php print($labels_string) ?>,
- tickmarks: 'circle'
- }
- }).trace2();
- };
- </script>
- <canvas id="cvs" width="600" height="250">
- [No canvas support]
- </canvas>
- </td></tr></table>
- </td><td></td></tr>
- </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement