date_add(now(), interval -7 day)"); $res_1day = mysqli_query($con,"SELECT avg(Discharge_cms) as Avg, max(Discharge_cms) as Max, min(Discharge_cms) as Min FROM IBWCtj where time_pst > date_add(now(), interval -1 day)"); //SELECT avg(Discharge_cms) as Avg, max(Discharge_cms) as Max, min(Discharge_cms) as Min, sum(Discharge_cms) as Sum FROM IBWCtj where time_pst > date_add(now(), interval -1 day); //get results starting with second row to eliminate partial day as seconds is full day //$res_daily = mysqli_query($con,"SELECT DATE(time_pst) date, avg(Discharge_cms) * 86400 * 264.17 / 1000000 MGPD FROM IBWCtj group by date order by date desc limit 1,14;"); $res_daily = mysqli_query($con,"SELECT DATE(time_pst) date, avg(Discharge_cms) * count(Discharge_cms) * 900 CuMeter FROM IBWCtj group by date order by date desc limit 14;");*/ //avg(Discharge_cms) * count(Discharge_cms) * 900 * 264.17 / 1000000 MGPD echo "

IBWC Tijuana River Flow Gauge

"; echo "

Data is provisional. Please visit IBWC Tijuana River data dashboard for authoritative data

"; while($row = mysqli_fetch_array($res_recent)) { echo "

Most recent: "; echo "" . number_format($row['Discharge_cms'] * 22.82, 1, '.', '') . " Million Gallons per Day (mgd) at " . $row['time_pst'] . " PST

"; } /* echo ""; $row = []; while($row = mysqli_fetch_array($res_1wk)) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } $row = []; while($row = mysqli_fetch_array($res_1day)) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; } //add other units and N echo "
Avg Discharge Max Discharge Min Discharge
CMS MGD CMS MGD CMS MGD
1 week" . number_format($row['Avg'], 1, '.', '') . "" . number_format(($row['Avg'] * 22.82), 1, '.', '') . "" . number_format($row['Max'], 1, '.', '') . "" . number_format(($row['Max'] * 22.82), 1, '.', '') . "" . number_format($row['Min'], 1, '.', '') . "" . number_format(($row['Min'] * 22.82), 1, '.', '') . "
24 hr" . number_format($row['Avg'], 1, '.', '') . "" . number_format(($row['Avg'] * 22.82), 1, '.', '') . "" . number_format($row['Max'], 1, '.', '') . "" . number_format(($row['Max'] * 22.82), 1, '.', '') . "" . number_format($row['Min'], 1, '.', '') . "" . number_format(($row['Min'] * 22.82), 1, '.', '') . "
";*/ mysqli_close($con); ?>
Zoom in x-axis by selecting/dragging a rectangle on chart