Hey Guys,
I've got a time clock database and I'm trying to run a report of people who were late for a shift. I'm pulling data from two tables (data and users) I have two time fields. One is time (VARCHAR with AM/PM, etc.) and the other is trutime (DATETIME field).
Here's the query:
Code:
SELECT data.date, data.time, data.trutime, data.reason, users.FirstName, users.LastName FROM data, users WHERE data.reason = 'morning_arrival' AND data.trutime BETWEEN '08:45:00' AND '10:00:00' ORDER BY data.date");
Here's what I'm getting:

Overages Report for month of January
Name Date Time Reason
Delilah Brantley 2013-01-16 08:51:49 am morning_arrival
Lychelle Allen 2013-01-16 08:51:49 am morning_arrival
Chris Woodburn 2013-01-16 08:51:49 am morning_arrival
Ellen Jones 2013-01-16 08:51:49 am morning_arrival
Heath Lee 2013-01-16 08:51:49 am morning_arrival
Anne Bowen 2013-01-16 08:51:49 am morning_arrival
Josh Sheffield 2013-01-16 08:51:49 am morning_arrival
Lychelle Allen 2013-01-17 08:45:02 am morning_arrival
Chris Woodburn 2013-01-17 08:45:02 am morning_arrival
Ellen Jones 2013-01-17 08:45:02 am morning_arrival
Heath Lee 2013-01-17 08:45:02 am morning_arrival
Anne Bowen 2013-01-17 08:45:02 am morning_arrival
Josh Sheffield 2013-01-17 08:45:02 am morning_arrival
Delilah Brantley 2013-01-17 08:45:02 am morning_arrival
As you can see, it's adding every user to every overage...I know it's a simple something, but blast if I can see it.
Just for reference, here's the php code to go with:
PHP Code:
<?php
    

        
//find overages     
        
$query mysql_query("SELECT data.date, data.time, data.trutime, data.reason, users.FirstName, users.LastName FROM data, users WHERE data.reason = 'morning_arrival' AND data.trutime BETWEEN '08:45:00' AND '10:00:00' ORDER BY data.date");
        
$check mysql_num_rows($query);
         if (
$check == 0) {
             die(
$query."<br/><br/>".mysql_error());
                 }
        else {
        while (
$result mysql_fetch_array$query ))   {
        
        
$first=$result['FirstName'];
        
$last=$result['LastName'];
        
$name$first " " $last;
        echo 
"<tr><td>";
        echo 
$name;
        echo 
"</td><td>";
        echo 
$result['date'];
        echo 
"</td><td>";
        echo 
$result['time'];
        echo 
"</td><td>";
        echo 
$result['reason'];
        echo 
"</td></tr>";
        
?>
Any help would be GREATLY appreciated!!!
Thanks in advance guys