\n”;
echo ‘Back to Query Page‘;
exit; }
//Add slashes to escape the apostrophe character and allow the SQL query to work properly
$tname = addslashes($tnameTemp);
/* Query to select trail details*/
$sql = “SELECT name, mlabel, trail_type,difficulty, startelev,endelev,highpoint,trlhd_direc,d_filename,prize,lpnts_id
FROM named_trails
WHERE name = ‘$tname'”;
/*Execute the query using prepared statements which are supposed to prevent and SQL Injection attack*/
//Create a placeholder for the array that goes into the pg_execute statement
$params = array();
//Prepare the query for execution
$stat = pg_prepare($connection,”,$sql);
//Execute the prepared Query
$stat = pg_execute($connection,”,$params);
/*Get the number of rows returned in the query */
$rows = pg_numrows($stat);
/*Check to see if the query executed*/
if ($rows <= 0) {
echo "We are currently updating the information for this trail. Please check back again soon.
n”;
exit;
}
$data = pg_fetch_array($stat);
/* Query to select Profile Info*/
$ProfileSql = “SELECT name, miles, contour
FROM point_elev
WHERE name = ‘$tname’
ORDER BY miles”;
/*Execute the query using prepared statements which are supposed to prevent and SQL Injection attack*/
//Create a placeholder for the array that goes into the pg_execute statement
$paramsProfile = array();
//Prepare the query for execution
$ProfileStat = pg_prepare($connection,”,$ProfileSql);
//Execute the prepared Query
$ProfileStat = pg_execute($connection,”,$paramsProfile);
/*Get the number of rows returned in the query */
$ProfileRows = pg_numrows($ProfileStat);
/*Check to see if the query executed*/
if ($ProfileRows <= 0) {
echo "We are currently updating the profile info for this trail.
n”;
exit;
}
/* Query to select Max Profile Info*/
$ProfileMaxSql = “SELECT MAX(miles) AS miles, MAX(contour) AS contour
FROM point_elev
WHERE name = ‘$tname’ “;
/*Execute the query using prepared statements which are supposed to prevent and SQL Injection attack*/
//Create a placeholder for the array that goes into the pg_execute statement
$paramsMaxProfile = array();
//Prepare the query for execution
$ProfileMaxStat = pg_prepare($connection,”,$ProfileMaxSql);
//Execute the prepared Query
$ProfileMaxStat = pg_execute($connection,”,$paramsMaxProfile);
$ProfileMaxData = pg_fetch_array($ProfileMaxStat, $i);
$ProfileMaxMiles=$ProfileMaxData[“miles”];
$ProfileMaxElev=(($ProfileMaxData[“contour”])+100);
/* Query to select Min Profile Info*/
$ProfileMinSql = “SELECT MIN(miles) AS miles, MIN(contour) AS contour
FROM point_elev
WHERE name = ‘$tname’ “;
/*Execute the query using prepared statements which are supposed to prevent and SQL Injection attack*/
//Create a placeholder for the array that goes into the pg_execute statement
$paramsMinProfile = array();
//Prepare the query for execution
$ProfileMinStat = pg_prepare($connection,”,$ProfileMinSql);
//Execute the prepared Query
$ProfileMinStat = pg_execute($connection,”,$paramsMinProfile);
/*Set the Minimum bounds for the Profile*/
$ProfileMinData = pg_fetch_array($ProfileMinStat, $i);
$ProfileMinMiles=$ProfileMinData[“miles”];
$ProfileMinElev=(($ProfileMinData[“contour”])-100);
/*Set the Y scale for the Profile*/
$ProfileScale=($ProfileMaxElev-$ProfileMinElev)/5;
/*Query to get the extents of the the trail */
$extent_select = “SELECT ST_EXTENT(ST_Transform(the_geom,4326))
FROM named_trails
WHERE name = ‘$tname’;”;
/*Execute the query using prepared statements which are supposed to prevent and SQL Injection attack*/
//Create a placeholder for the array that goes into the pg_execute statement
$paramsExtent = array();
//Prepare the query for execution
$extent_result = pg_prepare($connection,”,$extent_select);
//Execute the prepared Query
$extent_result = pg_execute($connection,”,$paramsExtent);
$extent_query = pg_fetch_row($extent_result,0);
/*Manipulate the extent string result into 4 variables*/
$extent_string = str_replace(” “,”,”,substr($extent_query[0],4,-1));
$extent_array = explode(“,”,$extent_string);
$minlon = (double)$extent_array[0];
$minlat = (double)$extent_array[1];
$maxlon = (double)$extent_array[2];
$maxlat = (double)$extent_array[3];
/*Set the difficulty rating*/
$dif_short = $data[“difficulty”];
switch ($dif_short) {
case “E”:
$trail_rating = “Easy”;
break;
case “M”:
$trail_rating = “Medium”;
break;
case “H”:
$trail_rating = “Challenging”;
break;
/*Set the Prize Variable*/
$prize = $data[“prize”];
}
/*Calculate the Elevation Change*/
$elev_change = abs($data[“startelev”]-$data[“highpoint”]);
/*Calculate Trail Type and distance*/
$trail_type_var = $data[“trail_type”];
$distance_var = $data[“mlabel”];
switch ($trail_type_var) {
case “loop”:
$trail_type= “Loop”;
$distance = $distance_var;
break;
case “one-way”:
$trail_type= “Point to Point”;
$distance = $distance_var;
break;
case “out-back”:
$trail_type= “Out & Back”;
$distance = $distance_var * 2;
break;
}
?>
- Name:
- Length: miles
- Level:
- Elevation Change: ft.
- Trail Type:
Interactive Trail Map
Use the +/- to zoom in and out click and drag the map to pan. The yellow line highlights your selected trail.
[map style=”width: auto; height:400px; margin:20px 0px 20px 0px; border: 1px solid black;” z=13 kml=]
Trail Profile
Distance in miles, Elevation in feet
$ProfileRows-1) {echo ‘,’;}
}
echo “&chds=”;
?>,&chco=74BF04&chm=B,93CA41,0,0,0&cht=lc&chxt=x,y&chxr=0,0,,1|1,,,&chxtc=1,-670″ alt=”trail profile” />
Directions to Trailhead:
Trail Details:‘;
include($TrailDetailFile);}
?>
“;
$lpntsAddress = $lpnts_prfx.””.$lpnts_id.””.$lpnts_sfx;
echo $lpntsAddress;
}
?>
There is a Treasure Hunt prize somewhere on this trail click HERE for more details.’;*/
?>