<?PHP include("config.php");
require_once("rating/classes/include.all.php");

$results = mysql_query("SELECT regionlong FROM ".$prefix."CoachesRegions WHERE regionid = '".intval(mysql_escape_string($_GET[region]))."' LIMIT 1") OR die(mysql_error());

if (mysql_num_rows($results) == 0) {
  header('Location: '.$site_url.'?mysql_error');
}

$row = mysql_fetch_array($results);
$regionname = $row[regionlong];
$selected_item = mysql_real_escape_string($_GET[region]);

$results = mysql_query("SELECT gf.coach_id, gf.coach_name, gf.coach_address, gf.coach_address_two, gf.coach_city, gf.coach_state, gf.coach_zip, gf.coach_phone, gf.coach_fax, gf.coach_email, gf.coach_website, gf.coach_certifications
FROM ".$prefix."Coaches AS gf
RIGHT JOIN ".$prefix."CoachesStates AS gts
ON gts.regionid = '".intval(mysql_escape_string($_GET[region]))."' AND gf.coach_state_tag = gts.statetag
WHERE gf.coach_valid = 1 ORDER BY gf.coach_name ASC") OR die(mysql_error());

$none = FALSE;
if (mysql_num_rows($results) == 0) {
  $none = TRUE;
}

// set the page title
$pagetitle = $regionname;

// set meta tags
$meta_keywords = "triathlon coaches in ".$regionname;
$meta_description = "Trying to find triathlon coaches in ".$regionname."? Here is a listing of all ".$regionname." triathlon coaches.";
?>

<? include("include_common_head.php"); ?>
<body class="listings">
  <? include($common_path . "/ads/ad_wallpaper.html"); ?>

  <div class="container">
    <? include($common_path . "/templates/include_header.php"); ?>
    <div class="main">
      <div class="contentwrapper clearfix">

        <? include("include_breadcrumb.php"); ?>

        <section class="section listings section-has-widgets section-static remove-sidebar">
          <div class="sidebar-b">
            <? include("include_sidebar.php"); ?>
          </div>
          <div class="content content-has-widgets">
            <div class="grid">

              <div class="clearfix">
                <h1 class="float-left">Triathlon Coaches</h1>
                <a href="<? echo $site_url ?>" class="btn btn-white float-right">Back</a>
                <? if (is_logged_in($user)) { ?>
                <a href="<? echo $site_url . "/add.php" ?>" class="btn btn-white float-right">Add Coach</a>
                <? } ?>
                <hr class="line" />
                <? include("../runshops/include_region_list.php"); ?>

                <h2><? echo $regionname ?> Region</h2>
                <hr />
                <?
                if($none == TRUE){
                echo "<p>No triathlon coaches have been entered yet for $regionname.</p>";
                }
                ?>

                <? while ($row = mysql_fetch_array($results)) {
                    include("include_store.php");
                } ?>

              </div><!-- end col-2/3 -->

            </div><!-- end grid -->
          </div><!-- end content -->
        </section>
          
      </div><!-- end contentwrapper -->
    </div> <!-- end main -->

  <? include($common_path . "/templates/include_footer.php") ?>
  </div> <!-- container  -->
</body>
<? include($common_path . "/templates/include_global_js.php") ?>
</html>
