Photovoltaik

[insert_php]
$con = mysql_connect(‚localhost‘,’c1enecsys‘,’kJxsM_OTu2′) or die(‚Could not connect to the server!‘);
mysql_select_db(‚c1enecsys‘) or die(‚Could not select a database.‘);
$sql = „SELECT SUM(dcpower),SUM(lifekwh) FROM energy t1 JOIN (SELECT serial, MAX(timestamp) max_timestamp FROM energy GROUP BY serial ) t2 ON t1.serial = t2.serial AND t1.timestamp = t2.max_timestamp“;
$result = mysql_query($sql) or die(‚A error occured: ‚ . mysql_error());
list($powersum,$lifesum) = mysql_fetch_row($result);
$sumstr = „Summe: „.$powersum.“ Wh (Gesamt: „.($lifesum/1000).“ kWh)„;
echo(„$sumstr“);
[/insert_php]