1
0
Fork 0

„index.php“ ändern

This commit is contained in:
Manuel Kamper 2023-06-24 13:43:15 +00:00
parent a9ce8cd789
commit 79e58e1fc3
1 changed files with 5 additions and 2 deletions

View File

@ -3,6 +3,7 @@ $servername = "sql-server-host";
$username = "solar";
$password = "password";
$dbname = "solar";
$price = 0.42;
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
@ -37,8 +38,10 @@ if ($result->num_rows > 0 && $result2->num_rows >0 && $result3->num_rows && $res
while($row = $result->fetch_assoc()) {
$row2 = $result2->fetch_assoc();
$row3 = $result3->fetch_assoc();
$row4 = $result4->fetch_assoc();
$jsonres = array("today"=>$row["today"], "yesterday"=>$row4["today"], "week"=>$row2["week"], "last_week"=>$row3["week"], "month"=>$row["month"], "year"=>$row["year"], "lifetime"=>$row["lifetime"], "current"=>$row["current"], "last_update"=>$row["last_update"]);
$row4 = $result4->fetch_assoc();
$saved_lifetime = round(($row["lifetime"] / 1000) * $price,2);
$saved_year = round(($row["year"] / 1000) * $price,2);
$jsonres = array("today"=>$row["today"], "yesterday"=>$row4["today"], "week"=>$row2["week"], "last_week"=>$row3["week"], "month"=>$row["month"], "year"=>$row["year"], "lifetime"=>$row["lifetime"], "current"=>$row["current"], "saved_lifetime"=>$saved_lifetime, "saved_year"=>$saved_year, "last_update"=>$row["last_update"]);
}
} else {
$jsonres = array("Error"=>"No result from database.");