setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); } catch(PDOException $e) { die ('Connection failed : '.$e->getMessage()); } //Get data dictionary $sql_data_dictionary = $db->prepare("SELECT term, definition FROM tblesddatadictionary ORDER BY term"); try { $sql_data_dictionary->execute(); } catch(PDOException $e) { die("Data Dictionary Query failed: ".$e->getMessage()); } $data_dictionary = $sql_data_dictionary->fetchAll(); //Get Site details $sql = "SELECT tblesdstations19.station_id, tblesdstations19.segment_id, tblesdstations19.short_desc, tblesdstations19.long_desc, tblesdstations19.latitude, tblesdstations19.longitude, tblesdstations19.waterbody_name, tblesdstations19.watershed_name, tblesdstations19.county_name, tblesdstations19.drainage_area, segment_basin_key.summary AS segment_summary, segment_basin_key.description AS segment_watershed_name, tblAUsStationsYearsTCEQ.auID, tblAUsDetailsTCEQ.SegmentName AS `segment_name` FROM tblesdstations19 Inner Join segment_basin_key ON segment_basin_key.segment_id = tblesdstations19.segment_id Inner Join tblAUsDetailsTCEQ ON tblAUsDetailsTCEQ.SegmentID = segment_basin_key.segment_id Left Outer Join tblAUsStationsYearsTCEQ ON tblAUsStationsYearsTCEQ.stationID = tblesdstations19.station_id WHERE tblesdstations19.station_id = :id LIMIT 1"; $sql_site_details = $db->prepare($sql); try { $sql_site_details->bindParam(':id', $station_id, PDO::PARAM_STR, 12); $sql_site_details->execute(); } catch(PDOException $e) { die("Site Details Query failed: ".$e->getMessage()); } $site_details = $sql_site_details->fetch(); //Determine if there are any relevant years for the Integrated Report. //If there are not report years for the last 3 report preiods, then the IR lnks will not be shown. $sql = "SELECT Count(tblAUsMainTCEQ.OBJECTID) as ir_year_count FROM tblAUsMainTCEQ WHERE tblAUsMainTCEQ.IR_YEAR >= date_format(date_sub(now(), interval 7 year), '%Y') AND tblAUsMainTCEQ.AU_ID = ?"; $sql_ir_year_count = $db->prepare($sql); $au_id = array($site_details['auID']); try { $sql_ir_year_count->execute($au_id); } catch(PDOException $e) { die("IR Year count Query failed: ".$e->getMessage()); } $ir_year_count = $sql_ir_year_count->fetch(); //Get Site images $sql = "SELECT filename as image_name, station_id, document_title FROM tblesdstationimages WHERE station_id = :id"; $sql_images = $db->prepare($sql); try { $sql_images->bindParam(':id', $station_id, PDO::PARAM_STR, 12); $sql_images->execute(); } catch(PDOException $e) { die("Site Images Query failed: ".$e->getMessage()); } $site_images = $sql_images->fetchAll(); // Find geometric mean for E.Coli $sql = "SELECT tblesdresult.result FROM tblesdresult Inner Join tblesdevent ON tblesdresult.tag_id = tblesdevent.tag_id WHERE tblesdresult.parameter_cd = 31699 AND tblesdevent.station_id = :id AND tblesdevent.end_date > date_sub(( SELECT max(`tblesdevent`.`end_date`) FROM `tblesdevent` JOIN `tblesdresult` ON `tblesdevent`.`tag_id` = `tblesdresult`.`tag_id` WHERE tblesdevent.station_id = :id AND tblesdresult.parameter_cd = '31699') , interval 10 year)"; $sql_geo_mean_ecoli = $db->prepare($sql); try { $sql_geo_mean_ecoli->bindParam(':id', $station_id, PDO::PARAM_STR, 5); $sql_geo_mean_ecoli->execute(); } catch(PDOException $e) { die("Site Images Query failed: ".$e->getMessage()); } $geo_mean_values = $sql_geo_mean_ecoli->fetchAll(); if (1 < count($geo_mean_values)) { $tot = count($geo_mean_values); $gm = 1; for ($i = 0; $i < $tot; $i++) { $gm = $gm * pow($geo_mean_values[$i]['result'],(1/$tot)); $gm1 = round($gm*100000)/100000; $geo_mean = $gm1; } } // Get results for each code to display on general info table $code_array = array('00300','00010','00400','00094','00940','00945','31699','00610','00620', '00665','72053'); $parameters = array(); function getCriteria($db,$bound,$code,$station, $segment) { $criteria = array(); $parameter = "parameter_".$code."_".$bound; $sql_default_criteria = $db->prepare("SELECT $parameter FROM tblesddefaultparameters WHERE tblesddefaultparameters.id = 1"); try { $sql_default_criteria->execute(); } catch(PDOException $e) { die("Default Criteria Query failed: ".$e->getMessage()); } $criteria['default'] = $sql_default_criteria->fetch(); $sql_segment_criteria = $db->prepare("SELECT $parameter FROM tblesddefaultparameters WHERE tblesddefaultparameters.segment_id = ?"); try { $sql_segment_criteria->execute(array($segment)); } catch(PDOException $e) { die("Segment Criteria Query failed: ".$e->getMessage()); } $criteria['segment'] = $sql_segment_criteria->fetch(); if (FALSE !== $station) { $sql_station_criteria = $db->prepare("SELECT $parameter FROM tblesddefaultparameters WHERE tblesddefaultparameters.station_id = ?"); try{ $sql_station_criteria->execute(array($station)); } catch(PDOException $e) { die("Station Criteria Query failed: ".$e->getMessage()); } $criteria['station'] = $sql_station_criteria->fetch(); } if (FALSE !== $criteria['station']) { foreach ($criteria['station'] as $key => $value) { if ($value !== NULL) { $station_criteria[$key] = $value; } else { $station_criteria[$key] = NULL; } } } if (FALSE !== $criteria['segment']) { foreach ($criteria['segment'] as $key => $value) { if (TRUE !== isset($station_criteria[$key])) { if ($value !== NULL) { $station_criteria[$key] = $value; } else { $station_criteria[$key] = NULL; } } } } foreach ($criteria['default'] as $key => $value) { if (TRUE !== isset($station_criteria[$key])) { if ($value !== NULL) { $station_criteria[$key] = $value; } else { $station_criteria[$key] = NULL; } } } return $station_criteria[$parameter]; } //Pull the last 10 yars worth of data from the last date a sample was taken foreach ($code_array as $code) { if ($code == "00094") { $calculations = "(SELECT MIN( CAST( tblesdresult.result as DECIMAL(8 , 2)) *.65) FROM tblesdresult Inner Join tblesdevent ON tblesdevent.tag_id = tblesdresult.tag_id WHERE tblesdevent.station_id = '".$station_id."' AND tblesdresult.parameter_cd = '".$code."' AND tblesdevent.end_date > date_sub(( SELECT max(`tblesdevent`.`end_date`) FROM `tblesdevent` JOIN `tblesdresult` ON `tblesdevent`.`tag_id` = `tblesdresult`.`tag_id` WHERE tblesdevent.station_id = '".$station_id."' AND tblesdresult.parameter_cd = '".$code."') , interval 10 year)) as min_result, (SELECT MAX( CAST( tblesdresult.result as DECIMAL(8 , 2)) *.65) FROM tblesdresult Inner Join tblesdevent ON tblesdevent.tag_id = tblesdresult.tag_id WHERE tblesdevent.station_id = '".$station_id."' AND tblesdresult.parameter_cd = '".$code."' AND tblesdevent.end_date > date_sub(( SELECT max(`tblesdevent`.`end_date`) FROM `tblesdevent` JOIN `tblesdresult` ON `tblesdevent`.`tag_id` = `tblesdresult`.`tag_id` WHERE tblesdevent.station_id = '".$station_id."' AND tblesdresult.parameter_cd = '".$code."') , interval 10 year)) as max_result, (SELECT AVG( CAST( tblesdresult.result as DECIMAL(8 , 2)) *.65) FROM tblesdresult Inner Join tblesdevent ON tblesdevent.tag_id = tblesdresult.tag_id WHERE tblesdevent.station_id = '".$station_id."' AND tblesdresult.parameter_cd = '".$code."' AND tblesdevent.end_date > date_sub(( SELECT max(`tblesdevent`.`end_date`) FROM `tblesdevent` JOIN `tblesdresult` ON `tblesdevent`.`tag_id` = `tblesdresult`.`tag_id` WHERE tblesdevent.station_id = '".$station_id."' AND tblesdresult.parameter_cd = '".$code."') , interval 10 year)) as avg_result,"; } else { $calculations = "(SELECT MIN( CAST( tblesdresult.result as DECIMAL(8 , 2))) FROM tblesdresult Inner Join tblesdevent ON tblesdevent.tag_id = tblesdresult.tag_id WHERE tblesdevent.station_id = '".$station_id."' AND tblesdresult.parameter_cd = '".$code."' AND tblesdevent.end_date > date_sub(( SELECT max(`tblesdevent`.`end_date`) FROM `tblesdevent` JOIN `tblesdresult` ON `tblesdevent`.`tag_id` = `tblesdresult`.`tag_id` WHERE tblesdevent.station_id = '".$station_id."' AND tblesdresult.parameter_cd = '".$code."') , interval 10 year)) as min_result, (SELECT MAX( CAST( tblesdresult.result as DECIMAL(8 , 2))) FROM tblesdresult Inner Join tblesdevent ON tblesdevent.tag_id = tblesdresult.tag_id WHERE tblesdevent.station_id = '".$station_id."' AND tblesdresult.parameter_cd = '".$code."' AND tblesdevent.end_date > date_sub(( SELECT max(`tblesdevent`.`end_date`) FROM `tblesdevent` JOIN `tblesdresult` ON `tblesdevent`.`tag_id` = `tblesdresult`.`tag_id` WHERE tblesdevent.station_id = '".$station_id."' AND tblesdresult.parameter_cd = '".$code."') , interval 10 year)) as max_result, (SELECT AVG( CAST( tblesdresult.result as DECIMAL(8 , 2))) FROM tblesdresult Inner Join tblesdevent ON tblesdevent.tag_id = tblesdresult.tag_id WHERE tblesdevent.station_id = '".$station_id."' AND tblesdresult.parameter_cd = '".$code."' AND tblesdevent.end_date > date_sub(( SELECT max(`tblesdevent`.`end_date`) FROM `tblesdevent` JOIN `tblesdresult` ON `tblesdevent`.`tag_id` = `tblesdresult`.`tag_id` WHERE tblesdevent.station_id = '".$station_id."' AND tblesdresult.parameter_cd = '".$code."') , interval 10 year)) as avg_result,"; } // Base query 1 to get results $sql_1 = $db->prepare("SELECT tblesdresult.parameter_cd, ".$calculations." COUNT(*) as num_samples, (SELECT STDDEV(tblesdresult.result) FROM tblesdresult Inner Join tblesdevent ON tblesdevent.tag_id = tblesdresult.tag_id WHERE tblesdresult.parameter_cd = '".$code."' AND tblesdevent.station_id = '".$station_id."'AND tblesdevent.end_date > date_sub(( SELECT max(`tblesdevent`.`end_date`) FROM `tblesdevent` JOIN `tblesdresult` ON `tblesdevent`.`tag_id` = `tblesdresult`.`tag_id` WHERE tblesdevent.station_id = '".$station_id."' AND tblesdresult.parameter_cd = '".$code."') , interval 10 year)) AS std_dev, tblesdevent.station_id, `tblesdstations19`.`segment_id` FROM tblesdresult Inner Join tblesdevent ON tblesdevent.tag_id = tblesdresult.tag_id Inner Join tblesdstations19 ON `tblesdstations19`.`station_id` = tblesdevent.station_id WHERE tblesdevent.station_id = ? AND tblesdresult.parameter_cd = ? GROUP BY tblesdresult.parameter_cd ORDER BY tblesdevent.end_date DESC"); try { $sql_1->execute(array($station_id, $code)); } catch(PDOException $e) { die("SQL 1 Results Query failed: ".$e->getMessage()); } $result_set_1 = $sql_1->fetch(); // Base query 2 to get results if ($code == "00094") { $calculations = "(CAST(tblesdresult.result as DECIMAL(8,2)) * .65) as result,"; } else { $calculations = "tblesdresult.result,"; } $sql_2 = $db->prepare("SELECT ".$calculations." tblesdresult.gtlt, DATE_FORMAT(tblesdevent.end_date,'%m/%e/%Y') as end_date, provisional_flg as provisional FROM tblesdresult Inner Join tblesdevent ON tblesdevent.tag_id = tblesdresult.tag_id Inner Join tblesdstations19 ON `tblesdstations19`.`station_id` = tblesdevent.station_id WHERE tblesdevent.station_id = ? AND tblesdresult.parameter_cd = ? ORDER BY tblesdevent.end_date DESC LIMIT 1"); //echo $sql_2 ."

"; try { $sql_2->execute(array($station_id, $code)); } catch(PDOException $e) { die("SQL 2 Results Query failed: ".$e->getMessage()); } $result_set_2 = $sql_2->fetch(); if (TRUE === is_array($result_set_1)) { $parameters[$code] = array_merge( $result_set_1, $result_set_2 ); } // Parameter long description $sql_long_description = $db->prepare("SELECT tblesdswparm.common_name, tblesdswparm.common_units, tblesdswparm.detailed_desc FROM tblesdswparm WHERE tblesdswparm.parameter_cd = :code"); try { $sql_long_description->bindParam(':code', $code, PDO::PARAM_STR); $sql_long_description->execute(); } catch(PDOException $e) { die("Long Description Query failed: ".$e->getMessage()); } $long_desc = $sql_long_description->fetch(); $parameters[$code]['common_name'] = $long_desc['common_name']; $parameters[$code]['common_units'] = $long_desc['common_units']; // If not last day since rainfal find min and max criteria levels if ($code !== '72053' && TRUE === isset($parameters[$code]['station_id']) && TRUE === isset($parameters[$code]['segment_id'])) { // Limit 1 insures you will get the most specific criteria definitions if defined (site, basic or general) $criteria_slug['criteria_max'] = getCriteria($db,'max',$code,$parameters[$code]['station_id'], $parameters[$code]['segment_id']); $criteria_slug['criteria_min'] = getCriteria($db,'min',$code,$parameters[$code]['station_id'], $parameters[$code]['segment_id']); if ($code == '00094') { $criteria_slug['criteria_max'] = (int) $criteria_slug['criteria_max']; $criteria_slug['criteria_min'] = (int) $criteria_slug['criteria_min']; } // Add criteria levels and result column conditional formating if (TRUE != is_null($criteria_slug['criteria_max']) && TRUE != is_null($criteria_slug['criteria_min']) ) { if ($criteria_slug['criteria_max'] == $criteria_slug['criteria_min']) { $parameters[$code]['criteria'] = $criteria_slug['criteria_max']; if ($parameters[$code]['result'] < $criteria_slug['criteria_max'] && $code == '00300') { $parameters[$code]['result_style'] = ' style="background:#fcc;"'; } else if ($parameters[$code]['result'] > $criteria_slug['criteria_max'] && $code != '00300') { $parameters[$code]['result_style'] = ' style="background:#fcc;"'; } else { $parameters[$code]['result_style'] = ' style="background:#cfc;"'; } if ($code == '00300') { $parameters[$code]['criteria'] = "> ".$parameters[$code]['criteria']; } else { $parameters[$code]['criteria'] = "< ".$parameters[$code]['criteria']; } } else { $parameters[$code]['criteria'] = $criteria_slug['criteria_min']." – ".$criteria_slug['criteria_max']; if ($parameters[$code]['result'] > $criteria_slug['criteria_max'] && $parameters[$code]['result'] > $criteria_slug['criteria_min']) { $parameters[$code]['result_style'] = ' style="background:#fcc;"'; } else if ($parameters[$code]['result'] < $criteria_slug['criteria_max'] && $parameters[$code]['result'] > $criteria_slug['criteria_min']) { $parameters[$code]['result_style'] = ' style="background:#cfc;"'; } else { $parameters[$code]['result_style'] = ' style="background:#fcc;"'; } } } } else { // If it is the last day since rain parameter... $parameters[$code]['criteria'] = ""; $parameters[$code]['result_style'] = ""; } // Get median value for parameter if (TRUE === isset($parameters[$code]['num_samples'])) { // Are there an even number of results? if ($parameters[$code]['num_samples']%2) { $half_1 = ($parameters[$code]['num_samples']/2)-.5; $half_2 = ($parameters[$code]['num_samples']/2)-.5; } else { $half_1 = ($parameters[$code]['num_samples']/2); $half_2 = ($parameters[$code]['num_samples']/2); } // Query to get median value(s). There will always be two resuls returned from // following query but if there is an odd number of results they will be the same value if ($code == "00094") { $calculations = "(CAST(tblesdresult.result as DECIMAL(8,2)) * .65) as result"; } else { $calculations = "CAST(tblesdresult.result as DECIMAL(8,2)) as result"; } // set up the temp table for the base median values $sql_median_values_temp_table = $db->prepare("CREATE TEMPORARY TABLE tmp ( n INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY, value VARCHAR(99) NOT NULL );"); try { $sql_median_values_temp_table->execute(); } catch(PDOException $e) { $sql_median_values_temp_table->debugDumpParams(); die("Median Temp Table Query failed: ".$e->getMessage()); } // Populate the temp table $sql_populte_median_values = $db->prepare("INSERT INTO tmp (value) (SELECT ".$calculations." FROM tblesdresult Inner Join tblesdevent ON tblesdevent.tag_id = tblesdresult.tag_id WHERE tblesdevent.station_id = :id AND tblesdresult.parameter_cd = :code AND tblesdevent.end_date > date_sub(( SELECT max(`tblesdevent`.`end_date`) FROM `tblesdevent` JOIN `tblesdresult` ON `tblesdevent`.`tag_id` = `tblesdresult`.`tag_id` WHERE tblesdevent.station_id = :id AND tblesdresult.parameter_cd = :code) , interval 10 year) ORDER BY cast(tblesdresult.result as decimal(8,2)) ASC);"); try { $sql_populte_median_values->bindParam(':id', $station_id, PDO::PARAM_STR, 5); $sql_populte_median_values->bindParam(':code', $code, PDO::PARAM_STR, 5); $sql_populte_median_values->execute(); } catch(PDOException $e) { $sql_populte_median_values->debugDumpParams(); die("Median Values Populate Query failed: ".$e->getMessage()); } // Determine how many rows are in the temp table $sql_median_values_total_rows = $db->prepare("SELECT COUNT(*) AS count FROM tmp;"); try { $sql_median_values_total_rows->execute(); } catch(PDOException $e) { $sql_median_values_total_rows->debugDumpParams(); die("Median Values total_rows Query failed: ".$e->getMessage()); } $median_values_total_rows = $sql_median_values_total_rows->fetch(); // Select the result from the temp table $sql_median_values = $db->prepare("SELECT avg(DISTINCT value) as median_result FROM tmp WHERE n IN (FLOOR((:count+1)/2), CEIL((@count+1)/2));"); try { $sql_median_values->bindParam(':count', $median_values_total_rows['count'], PDO::PARAM_INT, 5); $sql_median_values->execute(); } catch(PDOException $e) { $sql_median_values->debugDumpParams(); die("Median Values Query failed: ".$e->getMessage()); } $median_values = $sql_median_values->fetch(); // Drop the temp table $sql_drop_temp_table = $db->prepare("DROP TEMPORARY TABLE tmp;"); try { $sql_drop_temp_table->execute(); } catch(PDOException $e) { $sql_drop_temp_table->debugDumpParams(); die("Drop Median Values Temp Table Query failed: ".$e->getMessage()); } $parameters[$code]['median_result'] = $median_values['median_result']; $parameters[$code]['all'] = base64_encode(serialize($parameters[$code])); } } $latitude = $site_details['latitude']; $longitude = $site_details['longitude']; $station_id = $site_details['station_id']; $short_description = $site_details['short_desc']; $long_description = ucwords(strtolower($site_details['long_desc'])); $drainage_area = $site_details['drainage_area']; $county_name = $site_details['county_name']; $segment_watershed_name = $site_details['segment_watershed_name']; $watershed_name = $site_details['watershed_name']; $segment_id = $site_details['segment_id']; $segment_name = $site_details['segment_name']; $auID = $site_details['auID']; $segment_summary = nl2br($site_details['segment_summary']); $output = << .sample_table {background:#C1B782;border:1px solid #C1B782;} .sample_table td, .sample_table th {text-align:center; padding:2px; background:#fff; border:1px solid #C1B782;} .sample_table td.blank {background:#C1B782;} .sample_table td {padding:4px 2px;} .sample_table th {padding:4px 2px; background:#f4f2e9; } table td{ text-align: center !important; vertical-align: middle !important; } #map { width:100%; height: 500px; } .thumbnail-images { float: left; } .img-container-left { float: left; text-align: center; padding: 10px; padding-bottom: 0px; } .img-container-right { float: left; text-align: center; padding: 10px; padding-bottom: 0px; } div.img-container-right > img, div.img-container-left > img { height: 115px; } img.thumbnail-photos { cursor: zoom-in; } a:link { } .watershed_img_container img { width: 100%; height: auto; }

Station $station_id: $short_description

HTML; $storm_drainage_area = ''; $storm_drainage_area_acres = ''; $drainage_area_acres = $site_details['drainage_area'] * 640; if ($drainage_area === NULL || $drainage_area === '0') { $storm_drainage_area = 'Not Available'; $output .= <<$storm_drainage_area HTML; } else { $output .= <<$drainage_area mi2 HTML; } $output .= << HTML; if ($drainage_area_acres === NULL || $drainage_area_acres === 0) { $storm_drainage_area_acres = 'Not Available'; $output .= <<$storm_drainage_area_acres HTML; } else { $output .= <<$drainage_area_acres acres HTML; } $output .= << HTML; if($ir_year_count['ir_year_count'] > 0) { $output .= << HTML; } $output .= <<
Latitude $latitude
Longitude $longitude
Station Drainage Area
County $county_name
Watershed $watershed_name
Segment ID & Name $segment_id $segment_name
Assessment Unit ID $auID
Monitoring Data Download Data

Downstream

Upstream

Map

Station Summary Data

HTML; foreach ($parameters as $result_array) { $needle = array(',p',',d',',m',',f',',c',',n',',e','('); $string = array(', p',', d',', m',', f',', c',', n',', e','
('); if (1 < count($result_array)) { $output .= << HTML; if (isset($result_array['parameter_cd'])) { $num_samples = $result_array['num_samples']; if (TRUE === isset($result_array['min_result'])) { switch($result_array['parameter_cd']){ case '00094': $min_result = intval($result_array['min_result']); break; case '00094': $min_result = round($result_array['min_result']); break; default: $min_result = number_format($result_array['min_result'],1); } } else { $min_result = " "; } if (isset($result_array['max_result'])) { switch($result_array['parameter_cd']) { case '00094': $max_result = intval($result_array['max_result']); break; case '31699': $max_result = round($result_array['max_result']); break; default: $max_result = number_format($result_array['max_result'],1); } } else { $max_result = " "; } switch($result_array['parameter_cd']){ case '00094': $median_result = intval($result_array['median_result']); break; case '31699': $median_result = round($result_array['median_result']); break; default: $median_result = number_format($result_array['median_result'],1); } switch($result_array['parameter_cd']){ case '00094': $avg_result = intval($result_array['avg_result']); break; case '31699': $avg_result = round($result_array['avg_result']); break; default: $avg_result = number_format($result_array['avg_result'],1); } $std_dev = round($result_array['std_dev'], 1, PHP_ROUND_HALF_UP); $output .= <<$num_samples HTML; if ($result_array['parameter_cd'] == '31699') { if (round($geo_mean) > 126) { $output .= ""; } else { $output .= ""; } } else { $output .= <<  HTML; } } else { $output .= <<  HTML; } } $output.=" "; } $output .= <<

* Provisional Data - Water quality data pending review and acceptance by the Texas Commission on Environmental Quality (TCEQ).
** The E. coli grab sample criteria level is 399 MPN/100 mL. The criteria level for Geometric Mean is 126 MPN/100 mL.

HTML; foreach ($parameters as $parameter_modal) { $parameter_cd = $parameter_modal['parameter_cd']; $output .= << HTML; } // list of segment watershed maps saved on server. switch (strtolower($watershed_name)) { case 'lower san antonio river': $segment_url = 'lsar'; $image_name = 'lsar_watershed'; break; case 'upper san antonio river': $segment_url = 'usar'; $image_name = 'usar_watershed'; break; case 'cibolo creek': $segment_url = 'cibolo'; $image_name = 'cibolo_watershed'; break; case 'medina river': $segment_url = 'medina'; $image_name = 'medina_watershed'; break; case 'leon creek': $segment_url = 'leon'; $image_name = 'leon_watershed'; break; case 'salado creek': $segment_url = 'salado'; $image_name = 'salado_watershed'; break; case 'medio creek': $segment_url = 'medio'; $image_name = 'medio_watershed'; break; default: $segment_url = ''; $image_name = ''; break; } $output .= << HTML; return $output; }Basin Data – Water Quality Data

Basin Data

No data is available.
Parameter Most Recent Previous 10 Years from Last Collection Date
Units Criteria Level Results Collection Date # of Samples Min. Max. Med. Avg. Standard Deviation Geometric Mean
HTML; if (isset($result_array['common_name'])) { $double_asterisk = ($result_array['common_name'] == "E. coli") ? "**" : ""; if (isset($result_array['result'])) { $parameter_cd = $result_array['parameter_cd']; $common_name = str_replace($needle,$string,$result_array['common_name']); $output .= <<$common_name $double_asterisk HTML; } else { $output .= str_replace($needle,$string,strtolower($result_array['common_name']).$double_asterisk); } } else { $output .= "--"; } $common_units = $result_array['common_units']; $criteria = (isset($result_array['criteria']) && $result_array['criteria'] != "") ? $result_array['criteria'] : "--"; $result_style = isset($result_array['result_style']) ? $result_array['result_style'] : ''; if (isset($result_array['parameter_cd']) && (($result_array['parameter_cd'] == '00094') || ($result_array['parameter_cd'] == '31699') || ($result_array['parameter_cd'] == '72053'))) { $result = $result_array['gtlt'] . ' ' . (int) $result_array['result']; } else if (isset($result_array['result']) && (isset($result_array['parameter_cd']) && ($result_array['parameter_cd'] == '00610') || ($result_array['parameter_cd'] == '00665') )) { if ($result_array['result'] < 0.1) { $result = $result_array['gtlt'] . ' ' . $result_array['result']; } else if ($result_array['result'] >= 0.1 && $result_array['result'] <= 10) { $result = $result_array['gtlt'] . ' ' . $result_array['result']; } else { $result = $result_array['gtlt'] . ' ' . intval($result_array['result']); } } else if (isset($result_array['result']) && (isset($result_array['parameter_cd']) && ($result_array['parameter_cd'] == '00400'))) { $result = round($result_array['result'], 2, PHP_ROUND_HALF_UP); } else if (isset($result_array['result'])) { $result = round($result_array['result'], 2, PHP_ROUND_HALF_UP); } else { $result = "--"; } $end_date = isset($result_array['end_date']) ? $result_array['end_date'] : "--"; $provisional = (isset($result_array['provisional']) && 1 == $result_array['provisional']) ? "*": ""; $output .= << $common_units $criteria $result $end_date $provisional $min_result $max_result $median_result $avg_result $std_dev".round($geo_mean)."".round($geo_mean)."