Hi all,
I have a site that I archive/list records for each reporting period. (1qtr,2qtr,3qtr & 4qtr).
when the user logs in, the default is to list he 4qtr docs only. The user has the choice to switch reporting periods via a drop down menu. This all works great. Problem now is when the user tries to search via sites search engine, it only searches and returns the default period (4qtr). What I need to do I limit the search the selected or current time period. Here is my search code and select period code. Any advise on how to make the search engine only return results from the time period the user is in will be appreciated.
Main page,
$default_date ='4qtr';
if (!isset ($GET['date'])) {
$date= $default_date;
} else {
$date= $GET['period'];
}
$query .= " AND files.doc_date = '$date'";
<?
// this page also serves as the "search results" page
// if coming from the search form, $keyword and $where will exist
// so modify the query with additional constraints
if ($keyword != "" && isset($where))
{
// switch loop
switch ($where)
{
// description search
case 1:
$query .= " AND (files.acct LIKE '%$keyword%')";
break;
// filename search
case 2:
$query .= " AND (files.lname LIKE '%$keyword%')";
break;
// Rep ID search
case 3:
$query .= " AND (files.rep_id LIKE '%$keyword%')";
break;
// search all!
case 4:
$query .= " AND (files.acct LIKE '%$keyword%' OR files.lname LIKE '%$keyword%')";
break;
}
}
?>
<?
if ($date!= "" && isset($period))
{
// switch loop
switch ($period)
{
//1qtr
case 1:
$date='1qtr';
$query .= " AND (files.doc_date = '$date')";
break;
// 2qtr
case 2:date='2qtr';
$query .= " AND (files.doc_date = '$date')";
break;
//3qtr
case 3:
$date='3qtr';
$query .= " AND (files.doc_date = '$date')";
break;
//4qtr
case 4:
$date='4qtr';
$query .= " AND (files.doc_date = '$date')";
break;
}
}
?>
How can I make the search routine only search the the time period the user has selected?
This is the search form.
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
<form action="mfm.php" method="GET">
<tr>
<td align="right"><b>Enter Account Criteria </b><input type="Text" name="keyword" size="20"></td>
</tr>
<tr>
<td align="right"><b>Search </b><select name="where">
<option value="1">Account Number</option>
<option value="2">Account Name</option>
<option value="3">Account Rep</option>
<option value="4"selected>All</option>
</select></td>
</tr>
<tr>
<td colspan="2" align="right"><input type="Submit" name="submit" value="Search"></td>
</tr>
</form>
</td>
</tr>
</table>
Thanks in advance