Forum Moderators: coopster
My current DATE_RANGE.php page:
<form action="date_range_report_search.php" target="_self" style="display: inline; margin: 0;" method="post" name="formdate" id="formdate">
<table width="21%" border="0" align="center">
<tr>
<td colspan="2"><div align="center"><span class="style1">Date Range Report </span></div></td>
</tr>
<tr>
<td width="39%"><div align="right"><span class="style2">Between:</span></div></td>
<td width="61%"><span style="display: inline; margin: 0;">
<input type="text" name="date1" size="12" maxlength="25" value="" />
<a href="#" onclick="cal.select(document.forms['formdate'].date1,'anchor1','yyyy-MM-dd'); return false;"
name="anchor1" id="anchor1"><img src="cal_icon.gif" width="24" height="14" border="0" /></a></span></td>
</tr>
<tr>
<td><div align="right"><span class="style2">And:</span></div></td>
<td>
<input type="text" name="date2" size="12" maxlength="25" value="" />
<a href="#" onclick="cal.select(document.forms['formdate'].date2,'anchor2','yyyy-MM-dd'); return false;"
name="anchor2" id="anchor2"><img src="cal_icon.gif" width="24" height="14" border="0" /></a> </td>
</tr>
<tr>
<td> </td>
<td><span style="display: inline; margin: 0;">
<input type="submit" name="submit2332" value="View Report" />
</span></td>
</tr>
</table>
</form>
My current DATE_RANGE_SEARCH.php page:
<?php
include ('result_top_detail.inc');
require_once ('mysql_connect.php');
$date1 = $_POST['date1'];
$date2 = $_POST['date2'];
$query = "SELECT *, DATE_FORMAT(date, '%W (%d/%m/%y)') as dateFormatted
FROM `jobs` WHERE `date` BETWEEN '" . $date1 . "' AND '" . $date2 . "'";
$result = mysql_query($query);
while ($r = mysql_fetch_assoc($result)) {
extract($r);?>
<?php include('result_detail.inc');?>
<?php
$i++;
}
echo "</table>";
?>
I would need the standard date range boxes as i do now, but say 3 search boxes underneath (status, location, operator) and if they enter something in the status box it then searches for date range & status, and say they enter something in status and location, it then searches for date range + status + location.
Had a bunch of radio buttons on my original form page, like:
<input type="radio" name="checkbox" value="Date Range w/ Operator" />
if ($_POST["checkbox"] == "Date Range w/ Operator")
{
$query = "SELECT *, DATE_FORMAT(date, '%W (%d/%m/%y)') as dateFormatted
FROM `jobs` WHERE `date` BETWEEN '" . $date1 . "' AND '" . $date2 . "' AND operator = '" . $operator . "' ";
$result = mysql_query($query);
}
// initialize:
$whereClause = "WHERE `date` BETWEEN '" . $date1 . "' AND '" . $date2 . "';
// First Checkbox:
if ($_POST["checkbox"] == "Date Range w/ Operator") {
$whereClause .= [php.net] " AND operator = '" . $operator . "' ";
}
// Second Checkbox:
if ($_POST["someOtherCheckbox"] == "Some other checkbox") {
$whereClause .= [php.net] " AND operator = '" . $operator . "' ";
}
$query = "SELECT *, DATE_FORMAT(date, '%W (%d/%m/%y)') as dateFormatted
FROM `jobs` $whereClause";