Re: Select one row for each day
The only issue I see with this is having to specify the date range since it's being constantly displayed to a lighttpd website. This is what I ended up doing. I have this in my index.php:
v$result = mysqli_query($link, 'SELECT AIR_PRESSURE, DATE(CREATED) FROM WEATHER_MEASUREMENT GROUP BY DATE(CREATED) ORDER BY ID DESC LIMIT 7');
if (!$result)
{
$error = 'Error fetching 7 day: ' . mysqli_error($link);
include 'error.html.php';
exit();
}
while ($row = mysqli_fetch_array($result))
{
$sevdaypress[] = $row['AIR_PRESSURE'];
$datelist[] = $row['DATE(CREATED)'];
}
$myarray = array_combine($sevdaypress, $datelist);
and this in my readings.html.php:
color="#ED115A">
<?php foreach ($myarray as $sevenday=> $readingdate): ?>
<?php echo (' -- '.$readingdate. ' -- '. $sevenday)?><br>
<?php endforeach; ?>
My index.php has 'include readings.html.php' on the end of it. I am getting the results I want but if you see some unconventional syntax, I'm open to suggestions.
Subject
Written By
Posted
Re: Select one row for each day
April 27, 2017 07:45PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.