Jump to content

php mysql graph


jawood

Recommended Posts

Hi hoping someone can help with an issue im having displaying data from a MySQL database with php.

 

Attached is a copy of the code its the first graph at the top that I cant get to display the data.

 

It wont display the minutes along the bottom or draw the graph lines.

 

The page is located at www.inshome.net.au/dashboard.php

 

I have a feeling its to do with the getting the time from the table!

 

 

MYSQL table

 

id

event                 timestamp               current_timestamp

dht22temp         varchar(10)

humidity             varchar(10)

bmp180temp     varchar(10)

pressure            varchar(10)

altitude              varchar(10)

current0             varchar(10)

current1             varchar(10)

code.php

Link to comment
https://forums.phpfreaks.com/topic/294526-php-mysql-graph/
Share on other sites

A MySql type TIMESTAMP is not a unix-style timestamp but yyyy-mm-dd hh-ii-ss format.

Try

SELECT 
  TIMESTAMPDIFF(MINUTE, event, NOW()) as time1
  , dht22temp
  , humidity
  , pressure 
FROM sensordata 
WHERE event > NOW()-INTERVAL 2 HOUR
ORDER BY Time
Link to comment
https://forums.phpfreaks.com/topic/294526-php-mysql-graph/#findComment-1505421
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.