Hi,
I'm really hoping someone can help me. I've created a clocking system. The user clocks in,the clockin time is stored in the db, the user clocks out, the time is stored in the db. However, I want to store the difference, in other words the hours that would've been worked in the db for report generating. My two colums in the db are clock_in and clock_out.
This is what I've tried, I know the timediff() function works as I've tested it within mySql and it returns the difference, the problem is getting it from php to mysql.
$sql1 = mysql_query ("UPDATE clocking_system.clocking SET clock_out = NOW()
WHERE clock_out IS NULL");
$diff = mysql_query ("SELECT TIMEDIFF(clock_out, clock_in) AS time from clocking_system.clocking
where ID = '$_POST[id]' AND hours IS NULL"); //inserting the id and clock out time and hours worked into db
while($row = mysql_fetch_assoc($diff))
{
$hours = mysql_query ("UPDATE clocking_system.clocking SET hours = ".$row[0].
"WHERE hours IS NULL");
}
I would really appreciate any info or help, I've been searching for solutions to this problem, I'm very new to php and I would really appreciate a dig out here as my brain is melted. I'm sure it's something simple.