discourse-legacysite-perl/site/roadshow/search_X.php
2024-06-17 22:42:14 +10:00

518 lines
14 KiB
PHP

<?PHP
/** TO DO **
openwater_distance
openwater_distance_units
openwater_water_type
openwater_water_body
openwater_event_type
openwater_temperature
openwater_temperature_units
openwater_wetsuit_legal
openwater_wetsuit_allowed
************/
include("config.php");
if (!$_POST){ header('Location: '.$site_url); }
// build the SQL query
$sql = "SELECT * FROM ".$prefix.$main_table." WHERE ".$field_lead."valid = 1";
if (isset($_POST[stambassador])) {
$sql = $sql." AND ".$field_lead."stambassador = 1";
}
if (isset($_POST[triclub])) {
$sql = $sql." AND ".$field_lead."triclub = 1";
}
if (isset($_POST[coach])) {
$sql = $sql." AND ".$field_lead."coach = 1";
}
if (isset($_POST[racedirector])) {
$sql = $sql." AND ".$field_lead."racedirector = 1";
}
if (isset($_POST[brewery])) {
$sql = $sql." AND ".$field_lead."brewery = 1";
}
if (isset($_POST[trispecific])) {
$sql = $sql." AND ".$field_lead."trispecific = 1";
}
if (isset($_POST[fist])) {
$sql = $sql." AND ".$field_lead."fist = 1";
}
if (isset($_POST[fitbike])) {
if (in_array("999", $_POST[fitbike])) {
$sql = $sql." AND roadshow_fitbike <> '0'";
} else {
$sql = $sql." AND ( ";
$flag = 0;
foreach ($_POST[fitbike] AS $value) {
if ($flag == 1){
$sql = $sql." OR ";
}
$sql = $sql." roadshow_fitbike LIKE '%,$value' OR roadshow_fitbike LIKE '%,$value,%'";
$flag = 1;
}
$sql = $sql.")";
/**foreach ($_POST[fitbike] AS $value) {
$sql = $sql." AND roadshow_fitbike LIKE '%,$value,%'";
}**/}
}
if (isset($_POST[saddlechange])) {
if (in_array("999", $_POST[saddlechange])) {
$sql = $sql." AND roadshow_saddlechange <> '0'";
} else {
$sql = $sql." AND ( ";
$flag = 0;
foreach ($_POST[saddlechange] AS $value) {
if ($flag == 1){
$sql = $sql." OR ";
}
$sql = $sql." roadshow_saddlechange LIKE '%,$value' OR roadshow_saddlechange LIKE '%,$value,%'";
$flag = 1;
}
$sql = $sql.")";
/**foreach ($_POST[saddlechange] AS $value) {
$sql = $sql." AND roadshow_saddlechange LIKE '%,$value,%'";
}**/}
}
if (isset($_POST[motioncapture])) {
if (in_array("999", $_POST[motioncapture])) {
$sql = $sql." AND roadshow_motioncapture <> '0'";
} else {
$sql = $sql." AND ( ";
$flag = 0;
foreach ($_POST[motioncapture] AS $value) {
if ($flag == 1){
$sql = $sql." OR ";
}
$sql = $sql." roadshow_motioncapture LIKE '%,$value' OR roadshow_motioncapture LIKE '%,$value,%'";
$flag = 1;
}
$sql = $sql.")";
/**foreach ($_POST[motioncapture] AS $value) {
$sql = $sql." AND roadshow_motioncapture LIKE '%,$value,%'";
}**/}
}
if (isset($_POST[footbed])) {
if (in_array("999", $_POST[footbed])) {
$sql = $sql." AND roadshow_footbed <> '0'";
} else {
$sql = $sql." AND ( ";
$flag = 0;
foreach ($_POST[footbed] AS $value) {
if ($flag == 1){
$sql = $sql." OR ";
}
$sql = $sql." roadshow_footbed LIKE '%,$value' OR roadshow_footbed LIKE '%,$value,%'";
$flag = 1;
}
$sql = $sql.")";
/**foreach ($_POST[footbed] AS $value) {
$sql = $sql." AND roadshow_footbed LIKE '%,$value,%'";
}**/}
}
if (isset($_POST[wetsuit])) {
if (in_array("999", $_POST[wetsuit])) {
$sql = $sql." AND roadshow_wetsuit <> '0'";
} else {
$sql = $sql." AND ( ";
$flag = 0;
foreach ($_POST[wetsuit] AS $value) {
if ($flag == 1){
$sql = $sql." OR ";
}
$sql = $sql." roadshow_wetsuit LIKE '%,$value' OR roadshow_wetsuit LIKE '%,$value,%'";
$flag = 1;
}
$sql = $sql.")";
/**foreach ($_POST[wetsuit] AS $value) {
$sql = $sql." AND roadshow_wetsuit LIKE '%,$value,%'";
}**/}
}
if (isset($_POST[bike])) {
if (in_array("999", $_POST[bike])) {
$sql = $sql." AND roadshow_bike <> '0'";
} else {
$sql = $sql." AND ( ";
$flag = 0;
foreach ($_POST[bike] AS $value) {
if ($flag == 1){
$sql = $sql." OR ";
}
$sql = $sql."roadshow_bike LIKE '%,$value' OR roadshow_bike LIKE '%,$value,%'";
$flag = 1;
}
$sql = $sql.")";
/**foreach ($_POST[bike] AS $value) {
$sql = $sql." AND roadshow_bike LIKE '%,$value,%'";
}**/}
}
if (isset($_POST[diagnostic])) {
if (in_array("999", $_POST[diagnostic])) {
$sql = $sql." AND roadshow_diagnostic <> '0'";
} else {
$sql = $sql." AND ( ";
$flag = 0;
foreach ($_POST[diagnostic] AS $value) {
if ($flag == 1){
$sql = $sql." OR ";
}
$sql = $sql." roadshow_diagnostic LIKE '%,$value' OR roadshow_diagnostic LIKE '%,$value,%'";
$flag = 1;
}
$sql = $sql.")";
/**foreach ($_POST[diagnostic] AS $value) {
$sql = $sql." AND roadshow_diagnostic LIKE '%,$value,%'";
}**/}
}
if (isset($_POST[shoe])) {
if (in_array("999", $_POST[shoe])) {
$sql = $sql." AND roadshow_shoe <> '0'";
} else {
$sql = $sql." AND ( ";
$flag = 0;
foreach ($_POST[shoe] AS $value) {
if ($flag == 1){
$sql = $sql." OR ";
}
$sql = $sql." roadshow_shoe LIKE '%,$value' OR roadshow_shoe LIKE '%,$value,%'";
$flag = 1;
}
$sql = $sql.")";
/**foreach ($_POST[shoe] AS $value) {
$sql = $sql." AND roadshow_shoe LIKE '%,$value,%'";
}**/}
}
if (isset($_POST[sock])) {
if (in_array("999", $_POST[sock])) {
$sql = $sql." AND roadshow_sock <> '0'";
} else {
$sql = $sql." AND ( ";
$flag = 0;
foreach ($_POST[sock] AS $value) {
if ($flag == 1){
$sql = $sql." OR ";
}
$sql = $sql." roadshow_sock LIKE '%,$value' OR roadshow_sock LIKE '%,$value,%'";
$flag = 1;
}
$sql = $sql.")";
/**foreach ($_POST[sock] AS $value) {
$sql = $sql." AND roadshow_sock LIKE '%,$value,%'";
}**/}
}
if (isset($_POST[apparel_run])) {
if (in_array("999", $_POST[apparel_run])) {
$sql = $sql." AND roadshow_apparel_run <> '0'";
} else {
$sql = $sql." AND ( ";
$flag = 0;
foreach ($_POST[apparel_run] AS $value) {
if ($flag == 1){
$sql = $sql." OR ";
}
$sql = $sql." roadshow_apparel_run LIKE '%,$value' OR roadshow_apparel_run LIKE '%,$value,%'";
$flag = 1;
}
$sql = $sql.")";
/**foreach ($_POST[apparel_run] AS $value) {
$sql = $sql." AND roadshow_apparel_run LIKE '%,$value,%'";
}**/}
}
if (isset($_POST[apparel_tri])) {
if (in_array("999", $_POST[apparel_tri])) {
$sql = $sql." AND roadshow_apparel_tri <> '0'";
} else {
$sql = $sql." AND ( ";
$flag = 0;
foreach ($_POST[apparel_tri] AS $value) {
if ($flag == 1){
$sql = $sql." OR ";
}
$sql = $sql." roadshow_apparel_tri LIKE '%,$value' OR roadshow_apparel_tri LIKE '%,$value,%'";
$flag = 1;
}
$sql = $sql.")";
/**foreach ($_POST[apparel_tri] AS $value) {
$sql = $sql." AND roadshow_apparel_tri LIKE '%,$value,%'";
}**/}
}
if (isset($_POST[swimgear])) {
if (in_array("999", $_POST[swimgear])) {
$sql = $sql." AND roadshow_swimgear <> '0'";
} else {
$sql = $sql." AND ( ";
$flag = 0;
foreach ($_POST[swimgear] AS $value) {
if ($flag == 1){
$sql = $sql." OR ";
}
$sql = $sql." roadshow_swimgear LIKE '%,$value' OR roadshow_swimgear LIKE '%,$value,%'";
$flag = 1;
}
$sql = $sql.")";
/**foreach ($_POST[swimgear] AS $value) {
$sql = $sql." AND roadshow_swimgear LIKE '%,$value,%'";
}**/}
}
if (isset($_POST[bikeaccessory])) {
if (in_array("999", $_POST[bikeaccessory])) {
$sql = $sql." AND roadshow_bikeaccessory <> '0'";
} else {
$sql = $sql." AND ( ";
$flag = 0;
foreach ($_POST[bikeaccessory] AS $value) {
if ($flag == 1){
$sql = $sql." OR ";
}
$sql = $sql." roadshow_bikeaccessory LIKE '%,$value' OR roadshow_bikeaccessory LIKE '%,$value,%'";
$flag = 1;
}
$sql = $sql.")";
/**foreach ($_POST[bikeaccessory] AS $value) {
$sql = $sql." AND roadshow_bikeaccessory LIKE '%,$value,%'";
}**/}
}
if (isset($_POST[bikebody])) {
if (in_array("999", $_POST[bikebody])) {
$sql = $sql." AND roadshow_bikebody <> '0'";
} else {
$sql = $sql." AND ( ";
$flag = 0;
foreach ($_POST[bikebody] AS $value) {
if ($flag == 1){
$sql = $sql." OR ";
}
$sql = $sql." roadshow_bikebody LIKE '%,$value' OR roadshow_bikebody LIKE '%,$value,%'";
$flag = 1;
}
$sql = $sql.")";
/**foreach ($_POST[bikebody] AS $value) {
$sql = $sql." AND roadshow_bikebody LIKE '%,$value,%'";
}**/}
}
if (isset($_POST[bikecomponent])) {
if (in_array("999", $_POST[bikecomponent])) {
$sql = $sql." AND roadshow_bikecomponent <> '0'";
} else {
$sql = $sql." AND ( ";
$flag = 0;
foreach ($_POST[bikecomponent] AS $value) {
if ($flag == 1){
$sql = $sql." OR ";
}
$sql = $sql." roadshow_bikecomponent LIKE '%,$value' OR roadshow_bikecomponent LIKE '%,$value,%'";
$flag = 1;
}
$sql = $sql.")";
/**foreach ($_POST[bikecomponent] AS $value) {
$sql = $sql." AND roadshow_bikecomponent LIKE '%,$value,%'";
}**/}
}
if (isset($_POST[bikeelectronic])) {
if (in_array("999", $_POST[bikeelectronic])) {
$sql = $sql." AND roadshow_bikeelectronic <> '0'";
} else {
$sql = $sql." AND ( ";
$flag = 0;
foreach ($_POST[bikeelectronic] AS $value) {
if ($flag == 1){
$sql = $sql." OR ";
}
$sql = $sql." roadshow_bikeelectronic LIKE '%,$value' OR roadshow_bikeelectronic LIKE '%,$value,%'";
$flag = 1;
}
$sql = $sql.")";
/**foreach ($_POST[bikeelectronic] AS $value) {
$sql = $sql." AND roadshow_bikeelectronic LIKE '%,$value,%'";
}**/}
}
if (isset($_POST[bikehelmet])) {
if (in_array("999", $_POST[bikehelmet])) {
$sql = $sql." AND roadshow_bikehelmet <> '0'";
} else {
$sql = $sql." AND ( ";
$flag = 0;
foreach ($_POST[bikehelmet] AS $value) {
if ($flag == 1){
$sql = $sql." OR ";
}
$sql = $sql." roadshow_bikehelmet LIKE '%,$value' OR roadshow_bikehelmet LIKE '%,$value,%'";
$flag = 1;
}
$sql = $sql.")";
/**foreach ($_POST[bikehelmet] AS $value) {
$sql = $sql." AND roadshow_bikehelmet LIKE '%,$value,%'";
}**/}
}
if (isset($_POST[biketrainer])) {
if (in_array("999", $_POST[biketrainer])) {
$sql = $sql." AND roadshow_biketrainer <> '0'";
} else {
$sql = $sql." AND ( ";
$flag = 0;
foreach ($_POST[biketrainer] AS $value) {
if ($flag == 1){
$sql = $sql." OR ";
}
$sql = $sql." roadshow_biketrainer LIKE '%,$value' OR roadshow_biketrainer LIKE '%,$value,%'";
$flag = 1;
}
$sql = $sql.")";
/**foreach ($_POST[biketrainer] AS $value) {
$sql = $sql." AND roadshow_biketrainer LIKE '%,$value,%'";
}**/}
}
if (isset($_POST[bikewheel])) {
if (in_array("999", $_POST[bikewheel])) {
$sql = $sql." AND roadshow_bikewheel <> '0'";
} else {
$sql = $sql." AND ( ";
$flag = 0;
foreach ($_POST[bikewheel] AS $value) {
if ($flag == 1){
$sql = $sql." OR ";
}
$sql = $sql." roadshow_bikewheel LIKE '%,$value' OR roadshow_bikewheel LIKE '%,$value,%'";
$flag = 1;
}
$sql = $sql.")";
/**foreach ($_POST[bikewheel] AS $value) {
$sql = $sql." AND roadshow_bikewheel LIKE '%,$value,%'";
}**/}
}
if (isset($_POST[runhydrate])) {
if (in_array("999", $_POST[runhydrate])) {
$sql = $sql." AND roadshow_runhydrate <> '0'";
} else {
$sql = $sql." AND ( ";
$flag = 0;
foreach ($_POST[runhydrate] AS $value) {
if ($flag == 1){
$sql = $sql." OR ";
}
$sql = $sql." roadshow_runhydrate LIKE '%,$value' OR roadshow_runhydrate LIKE '%,$value,%'";
$flag = 1;
}
$sql = $sql.")";
/**foreach ($_POST[runhydrate] AS $value) {
$sql = $sql." AND roadshow_runhydrate LIKE '%,$value,%'";
}**/}
}
if (isset($_POST[bodycare])) {
if (in_array("999", $_POST[bodycare])) {
$sql = $sql." AND roadshow_bodycare <> '0'";
} else {
$sql = $sql." AND ( ";
$flag = 0;
foreach ($_POST[bodycare] AS $value) {
if ($flag == 1){
$sql = $sql." OR ";
}
$sql = $sql." roadshow_bodycare LIKE '%,$value' OR roadshow_bodycare LIKE '%,$value,%'";
$flag = 1;
}
$sql = $sql.")";
/**foreach ($_POST[bodycare] AS $value) {
$sql = $sql." AND roadshow_bodycare LIKE '%,$value,%'";
}**/}
}
// add date range
if (isset($_POST['futuredates']) OR $_POST['keyword'] == "") {
if ($_POST[aftermonth] != 0 AND $_POST[afterday] != 0) {
$afterdate = "$_POST[afteryear]-$_POST[aftermonth]-$_POST[afterday]";
$sql = $sql." AND date >= '$afterdate'"; }
else { $sql = $sql." AND ".$field_lead."date >= NOW()"; }
if ($_POST[beforemonth] != 0 AND $_POST[beforeday] != 0) {
$beforedate = "$_POST[beforeyear]-$_POST[beforemonth]-$_POST[beforeday]";
$sql = $sql." AND ".$field_lead."date <= '$beforedate'";
}
} else {
$last_year = time() - 365*24*60*60;
$sql = $sql." AND date >= '".date('Y-m-d', $last_year)."'";
}
// regions are checkboxes that then check off all states within that region
// add states
if (isset($_POST[states])) {
$glue = "','";
$statelist = "('".implode($glue, $_POST[states])."')";
$sql = $sql." AND ".$field_lead."state_tag IN $statelist";
}
$sql = $sql." ORDER BY ".$field_lead."date ASC";
//echo $sql;
//exit();
$results = mysql_query($sql);
$none = FALSE;
if (mysql_num_rows($results) == 0) {
$none = TRUE;
}
$race_count = mysql_num_rows($results);
// set the page title
$pagetitle = "Search Results";
// set meta tags
$meta_keywords = "roadshow events in matching a user's search query.";
$meta_description = "A list of matching roadshow events.";
?>
<? 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">
<h1><? echo $race_count ?> Roadshow Events Match Your Search</h1>
<hr class="line">
<? if ($none == TRUE) {
echo "<p>No races match your search</p>";
}
?>
<ul>
<? while($row = mysql_fetch_array($results)) { ?>
<li>
<p>
<a class="sub-hdr" href="<? echo "individual.php?roadshow_id=$row[roadshow_id]"; ?>"><? echo $row[roadshow_name]; ?></a><br>
<strong>Address:</strong> <? echo ("$row[roadshow_address]"); if($row[roadshow_address_two]) { echo (" - $row[roadshow_address_two]"); } echo(", $row[roadshow_city], $row[roadshow_state] $row[roadshow_zip]"); ?><br>
<strong>Date:</strong> <? echo $row[roadshow_date]; ?><br />
<a href="<? echo "individual.php?roadshow_id=$row[roadshow_id]"; ?>">More information</a>
</p>
</li>
<? } ?>
</ul>
</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>