I have created a web site that has a search engine my problem is that under the admin section i have created a drop down that contains a list of tables of related athlete information for each year of the race. On my site i have a created a search engin that can search the table for an athlets proformance for that year. But what i am attempting to do is have the admin select the year they person on the site can search through the search box. Or i was thinking about having the user select the table year from a drop down. i am not sure how to do this though. What i have writen is bellow. the site is www.ozarkvalleytriathlon.com
here is the admin section i was thinking about
<?php
//print ($_POST['chooseTable']);
if(isset($_POST['upload']) && $_POST['chooseTable'] > 0)
{
$chooseT = $_POST['chooseTable'];
if ($_POST['chooseTable'] != "none")
{
// connection to dba
$hostname_mydba = "localhost";
$database_mydba = "ResultsDB";
$username_mydba = "root";
$password_mydba = "passwd";
$mydba = mysql_connect($hostname_mydba, $username_mydba, $password_mydba) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database_mydba);
echo "uploaded";
}
else
echo "failed to upload";
}
?>
<form name="form1" method="get" action="searchresult.php">
<table class="formBg" align="center" width="35%" border="1" cellspacing="0" cellpadding="2">
<tr valign="top">
<td width="50%">
<select class="dropdownMedium" name="searchTable" id="searchTable">
<option selected value="none">-- Select Search Table --</option>
<?php setSearchTableName(); ?>
</select>
<input class="medium" type="hidden" name="TableName" value="<?php print(unFormatData($row[1])); ?>">
</td>
</tr><tr valign="top">
<td width="50%">
<input name="upload" type="submit" class="box" id="upload" value="Set Search Table">
</td>
</tr>
</table>
</form>
here is the form for the search
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<tr>
<td align="right">First Name:</td>
<td align="right"><input name="SearchString" type="text" id="SearchString" size="6"></td>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td> <input type="submit" name="Submit" value="Go"></td>
</tr>
</table>
this is the portion that gets called when the user hits submit.
<?php require_once('Connections/connBlog.php'); ?>
<?php $SearchString=$_GET['SearchString'];?>
<?php $searchTable=$_GET['searchTable'];?>
<?php
mysql_select_db($database_connBlog, $connBlog);
$searchTable
$query_rsTopics = "SELECT * FROM searchTable ORDER BY Place ASC";
$rsTopics = mysql_query($query_rsTopics, $connBlog) or die(mysql_error());
$row_rsTopics = mysql_fetch_assoc($rsTopics);
$totalRows_rsTopics = mysql_num_rows($rsTopics);
$SearchString_rsSearchResults = "-1";
if (isset($_GET['SearchString'])) {
$SearchString_rsSearchResults = (get_magic_quotes_gpc()) ? $_GET['SearchString'] : addslashes($_GET['SearchString']);
}
mysql_select_db($database_connBlog, $connBlog);
$query_rsSearchResults = sprintf("SELECT * FROM searchTable WHERE BibNo like '%%%s%%' OR FirstName like '%%%s%%' OR LastName like '%%%s%%' ORDER BY BibNo DESC", $SearchString_rsSearchResults,$SearchString_rsSearchResults,$SearchString_rsSearchResults);
$rsSearchResults = mysql_query($query_rsSearchResults, $connBlog) or die(mysql_error());
$row_rsSearchResults = mysql_fetch_assoc($rsSearchResults);
$totalRows_rsSearchResults = mysql_num_rows($rsSearchResults);
?>
<?php include("func_def.php"); ?>
<?php include("incfiles/ozark_admin.php"); ?>
<?php
// This section is only run when the form has been submitted
if($HTTP_POST_VARS['Submit']=='Login'){
session_start();
// Check whether the login details are correct, and put
// the user status into a session variable.
$statusCheck = check_login($HTTP_POST_VARS);
if ($statusCheck == "Admin" || $statusCheck == "Staff"){
session_register("statusCheck");
header("Location: adminMenu.php");
}
}
?>
<?php include("./incfiles/i_header.inc"); ?>
<!-- Body of Page below here -->
<div id="c-block">
<table width="770" border="0" cellspacing="0" cellpadding="0"><!--DWLayoutTable-->
<tr valign="top">
<td valign="top" class="lh-col">
<?php include("./incfiles/i_menu.inc"); ?>
</td>
<td class="c-col" valign="top">
<?php if ($totalRows_rsSearchResults > 0) { // Show if recordset not empty ?>
<table width="auto" border="1" cellpadding="0" cellspacing="0" class="topic">
<tr class="nugheader">
<td colspan="24">Search results for: <strong><?php echo $_GET['SearchString']; ?></strong></td>
</tr>
<?php //searchTable
$sql = "SELECT * FROM `searchTable` WHERE 1";
$result = mysql_query($sql);
echo '<tr>';
$topRow = mysql_fetch_row($result);
echo "<td bgcolor='cccccc'>" .$topRow[0]. "</td>";
echo "<td bgcolor='cccccc'>" .$topRow[1]. "</td>";
echo "<td bgcolor='cccccc'>" .$topRow[2]. "</td>";
echo "<td bgcolor='cccccc'>" .$topRow[3]. "</td>";
echo "<td bgcolor='cccccc'>" .$topRow[7]. "</td>";
echo "<td bgcolor='cccccc'>" .$topRow[9]. "</td>";
echo "<td bgcolor='cccccc'>" .$topRow[11]. "</td>";
echo "<td bgcolor='cccccc'>" .$topRow[13]. "</td>";
echo "<td bgcolor='cccccc'>" .$topRow[15]. "</td>";
echo "<td bgcolor='cccccc'>" .$topRow[17]. "</td>";
echo "<td bgcolor='cccccc'>" .$topRow[19]. "</td>";
echo "<td bgcolor='cccccc'>" .$topRow[20]. "</td>";
echo '</tr>';
?>
<?php do { ?>
<tr class="topheader">
<td><?php echo str_replace($SearchString, "<strong>$SearchString</strong>",$row_rsSearchResults['Place']);?></td>
<td><?php echo str_replace($SearchString, "<strong>$SearchString</strong>",$row_rsSearchResults['BibNo']);?></td>
<td><?php echo str_replace($SearchString, "<strong>$SearchString</strong>",$row_rsSearchResults['FirstName']);?></td>
<td><?php echo str_replace($SearchString, "<strong>$SearchString</strong>",$row_rsSearchResults['LastName']);?></td>
<td><?php echo str_replace($SearchString, "<strong>$SearchString</strong>",$row_rsSearchResults['Division']);?></td>
<td><?php echo str_replace($SearchString, "<strong>$SearchString</strong>",$row_rsSearchResults['Swim']);?></td>
<td><?php echo str_replace($SearchString, "<strong>$SearchString</strong>",$row_rsSearchResults['T1']);?></td>
<td><?php echo str_replace($SearchString, "<strong>$SearchString</strong>",$row_rsSearchResults['Bike']);?></td>
<td><?php echo str_replace($SearchString, "<strong>$SearchString</strong>",$row_rsSearchResults['T2']);?></td>
<td><?php echo str_replace($SearchString, "<strong>$SearchString</strong>",$row_rsSearchResults['Run']);?></td>
<td><?php echo str_replace($SearchString, "<strong>$SearchString</strong>",$row_rsSearchResults['Penalty']);?></td>
<td><?php echo str_replace($SearchString, "<strong>$SearchString</strong>",$row_rsSearchResults['Overall']);?></td>
</tr>
<?php } while ($row_rsSearchResults = mysql_fetch_assoc($rsSearchResults)); ?>
</table>
<?php } // Show if recordset not empty ?>
<?php if ($totalRows_rsSearchResults == 0) { // Show if recordset empty ?>
<table width="auto" border="0" cellpadding="0" cellspacing="0" class="topic">
<tr>
<td>Sorry! There are no entries containing the search string <?php echo $_GET['SearchString']; ?></td>
</tr>
</table>
<p> </p>
<?php } // Show if recordset empty ?>
</td>
<td valign="top" class="rh-col">
<?php include("./incfiles/i_menuR.inc"); ?>
</td>
</tr>
</table>
</div>
<div id="bottom_bar"></div>
<div id="copyright"> Copyright © 2004 Ozark Valley Triathlon
Desgined by <a href="http://www.nathanaelmiller.com">Nathanael Miller.</a> </div>
</div>
</div>
</BODY>
</HTML>