Ok, this has stumped me and I think I'm getting more and more confused the more I try to resolve it.
I'm running a check on a database table after a form submission - basically, I want to ensure that a user cannot enter more than 8 hours for a single date in a timesheeting system.
So I run a query on the database for the sum of hours for the userID and date. UserID is equal to the session uid and the date is the date input on the form.
This is what I have ...
Doesn't work! Obviously.
So, how do I get a numeric result from the database and add it to the number of hours posted?
I'm running a check on a database table after a form submission - basically, I want to ensure that a user cannot enter more than 8 hours for a single date in a timesheeting system.
So I run a query on the database for the sum of hours for the userID and date. UserID is equal to the session uid and the date is the date input on the form.
This is what I have ...
Code:
$q_dupcheck = "select sum(hours) from ts_entry where user_id='$_SESSION[uid]' and date='$newdate'";
$dup_check = mysql_query($q_dupcheck);
$total_hours = $dup_check + $_POST['hours'];
if ($total_hours <= 8) {
blah, blah, blah
Doesn't work! Obviously.
So, how do I get a numeric result from the database and add it to the number of hours posted?