Hi,
First, I apologize, but I am a biologist not a programmer!
Second, I made a web-based scheduling system in mysql. It works great but I need to generate a report by specifying a range of dates on another webpage.
I made the query to give me the columns I want, but I don't know how to create the front-end page on which I would like select the range of dates to show me. Here is the query that returns ALL records:
<?
// script to display all reservations
// connection information
$hostName = "localhost";
$userName = "*********";
$password = "**********";
$dbName = "************";
// make connection to database
mysql_connect($hostName, $userName, $password) or die("Unable to connect to host $hostName");
mysql_select_db($dbName) or die( "Unable to select database $dbName");
// Select all the fields in all the records of the Computers table
$query = "SELECT li.fname Name, li.lname Last_Name, rs.name Equipment, rv.summary Project, (TO_DAYS( from_unixtime( rv.end_date ) ) - TO_DAYS( from_unixtime( rv.start_date ) )) + 1 Days_Out , rs.notes ID_Cost
FROM reservations rv, resources rs, reservation_users ru, login li
WHERE rs.machid = rv.machid
AND ru.resid = rv.resid
AND li.memberid = ru.memberid
AND from_unixtime( rv.end_date ) <= CURRENT_DATE( )
UNION
SELECT li.fname Name, li.lname Last_Name, rs.name Equipment, rv.summary Project, (TO_DAYS( CURRENT_DATE( ) ) - TO_DAYS( from_unixtime( rv.start_date ))) + 1 Days_Out, rs.notes ID_Cost
FROM reservations rv, resources rs, reservation_users ru, login li
WHERE rs.machid = rv.machid
AND ru.resid = rv.resid
AND li.memberid = ru.memberid
AND from_unixtime( rv.end_date ) > CURRENT_DATE( )
AND from_unixtime( rv.start_date ) < CURRENT_DATE()
ORDER BY 4
LIMIT 0 , 30";
$result = mysql_query($query);
// Determine the number of computers
$number = mysql_numrows($result);
// print the computer names
print "<h2>There are $number equipment charge-outs between your specified date and now:</h2>
<table cellpadding=5>
<tr bgcolor=black>
<td><font color=white><b>Name</b></font></td>
<td><font color=white><b>Equipment</b></font></td>
<td><font color=white><b>Project</b></font></td>
<td><font color=white><b>Days_Out</b></font></td>
<td><font color=white><b>ID_Cost</b></td></font></tr>";
for ($i=0; $i<$number; $i++) {
$Name = mysql_result($result,$i,"Name");
$Last_Name = mysql_result($result,$i,"Last_Name");
$Equipment = mysql_result($result,$i,"Equipment");
$Project = mysql_result($result,$i,"Project");
$Days_Out = mysql_result($result,$i,"Days_Out");
$ID_Cost = mysql_result($result,$i,"ID_Cost");
// print "$a $b $c $d $e $f $g<br>";
if ($i%2 == 0) {
print "<tr bgcolor=lightgrey>";
} else {
print "<tr>";
}
print "<td>$Name $Last_Name</td>
<td>$Equipment</td>
<td>$Project</td>
<td>$Days_Out</td>
<td>$ID_Cost</td></tr>";
}
print "</table>";
// Close the database connection
mysql_close();
?>
<p>