Hi all,
I have a site that I archive & list documents 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.
Query results are returned to the same page regardless of selected
time period. 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). 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 has selected, will be appreciated.
//Main page, select user time period or use default this is passed by the switch to ($period)
$default_date ='4qtr';
if (!isset ($_GET['date'])) {
$date= $default_date;
} else {
$date= $_GET['period'];
}
** I think this is my problem, page does not get the period passed on by the select period switch
//This is where the orninginal query is modified
$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;
}<!-- main menu -->
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
** or my search form is not passing the currect time period to the
search query
<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>
}
?>