2019 Little Bay

[insert_php]
$db = new mysqli(‘localhost’, ‘chadwick_waterne’, ‘mYc!ean_?Water16’, ‘chadwick_waterdata’);
$beachID = isset($_GET[‘beachid’]) ? $_GET[‘beachid’] : 4;
$beachData = array();
$beachName = “noName”;
$useYear = ‘2019’;
$useYear = date(‘Y-m-d’, strtotime($useYear . ‘-01-01’));

if($db->connect_errno > 0){
die(‘Unable to connect to database [‘ . $db->connect_error . ‘]’);
}

// Retrieve Beach Name
$beachQuery = “SELECT `Beach` FROM `tblBeachNew` WHERE `BeachID`='{$beachID}’ LIMIT 1;”;
if(!$beachTable = $db->query($beachQuery)) {
die(“error getting [{$db->error}]”);
}
while($beachRow = $beachTable->fetch_assoc()) {
$beachName = $beachRow[‘Beach’];
}

// Retrieve data for beach,
$sql = “SELECT `Date`, `Ecoli`, `Faecal`, `Coliform` FROM `tblBeachResultsNew` WHERE `BeachID`='{$beachID}’ AND YEAR(`Date`)='{$useYear}’ ORDER BY `Date` DESC;”;

if(!$result = $db->query($sql)) {
die(‘error getting [‘ . $db->error . ‘]’);
}
while($row = $result->fetch_assoc()) {
$beachData[] = array(
‘date’ => date(‘j M Y’, strtotime($row[‘Date’])),
‘ecoli’ => $row[‘Ecoli’],
‘faecal’ => $row[‘Faecal’]
);
}

[/insert_php]

[insert_php] echo $beachName; [/insert_php]

[insert_php]
$mm=1;
foreach($beachData as $day) {

if($mm==1)
{
$day123=$day[‘date’];

$ecoli123=$day[‘ecoli’];
$faecal123=$day[‘faecal’];
}
$mm++;

}

[/insert_php]

[insert_php] echo $beachData[0][‘date’]; [/insert_php]

[insert_php]
if ($ecoli123<=500 AND $faecal123<=185) { echo '‘;

} else {

echo ‘‘;

}
[/insert_php]

Date E.COLI Intestinal enterococci
Acceptable Water Water Quality ≤500 ≤185
Low Water Water Quality
>500 >185
[insert_php]
foreach($beachData as $day) {
$class = ”;
$class2 = ”;
echo ‘

‘;
echo ‘

‘;
if($day[‘ecoli’] >= 500) {
$class = ‘ class=”bad”‘;
}
echo ‘

‘;
if($day[‘faecal’] >= 185) {
$class2 = ‘ class=”bad”‘;
}
echo ‘

‘;
echo ‘

‘;
}
[/insert_php]

‘ . $day[‘date’] . ‘ ‘ . $day[‘ecoli’] . ‘ ‘ . $day[‘faecal’] . ‘