Sorry acousticmarc, I accidentally removed your thread!! - Ronald
Hello, first time post here and novice php user.
Man, this is frustrating the hell out of me. I've got a timecard database that goes way back, to the early 90's. I've created a form that will select the employee_id as well as any particular contract_id associated with that employee, hours and billing date. What I really want to do is be able to select a date range "starting on" date and "finishing on" this date. All attempts have been thwarted. Could someone please lend a hand?
[php]
<HTML>
<HEAD>
<script language="javascript" src="cal2.js"> <--Java popup calendar to select the date
</script>
<script language="javascript" src="z3.js"></script>
<TITLE>Query the timecard database</TITLE>
</HEAD>
<BODY>
<form name="form1" method="POST" action="z2.php">
<p> Select Employee<select name="Employee_ID" id="Employee_ID">
<option value="3">Steve</option>
<option value="14">Marc</option>
</select>
<p>Select Contract<select name="Contract_ID" id="Contract_ID">
<option value="Contract_ID">All</option>
<option value="10510">C</option>
<option value="10600">A</option>
</select>
<br>
<input type="text" name="firstinput" size=20>
<a href="javascript:showCal('Calendar1')">
<IMG SRC="/small.gif" border=0></IMG></a><br>
<p><input type="submit" name="submit" value="submit">
</form>
</BODY>
</HTML>
Then everything gets passed to z2.php
<?
$host = "localhost";
$user = "user";
$pass = "password";
$dbname = "database";
$connection = mysql_connect($host,$user,$pass) or die (mysql_errno().": ".mysql_error()."");
mysql_select_db($dbname);
$sql = "select * from time_billed where Employee_ID=" . $_POST['Employee_ID'] . " AND Contract_ID=" . $_POST['Contract_ID'] . " AND firstinput>=" . $_POST['firstinput'] . " ORDER BY BILLING_DATE DESC";
$query = mysql_query($sql);
echo "<table border='1'>";
echo "<tr> <th>Contract</th> <th>Employee</th> <th>Date</th> <th>Hours</th> </tr>";
while ($row = mysql_fetch_array($query)) {
echo "<tr><td>";
echo $row['Contract_ID'];
echo "</td><td>";
echo $row['Employee_ID'];
echo "</td><td>";
echo $row['Billing_Date'];
echo "</td><td>";
echo $row['Billing_Hours'];
echo "</td></tr>";
}
echo "</table>";
?>
[/php]
The data format is yyyy-mm-dd....how can I retrieve the $sql statement and have it return the results that are > the firstinput range I specified?
Thank you in advance.