I am a little bit stuck with a PHP script.
The script is for a radio station and it needs to do the following:
Count how many times a radio presenter has booked a slot for the current day. The slots are stored in a table in a database and I would use the code
date("l")to determine the current day and then search for all rows which have "day" set to whatever the value ofdate("l")is.Then I would need to find out how many hours the presenter already has stored in the "monthly_slots" column in the "users" table in the row which has their username.
"SELECT monthly_slots FROM users"Then I'd need to add whatever the value of the amount of slots the presenter has completed today with the amount of slots which already exist in the monthly_slots column.
Below is my code for this
$currentday = date("l");
$currentslots = mysql_query("SELECT monthly_slots FROM users");
mysql_query("
UPDATE users
SET slots = (SELECT COUNT(*) + "$currentslots"
FROM timetable
WHERE timetable.username = users.username
AND day = "$currentday"
)
");
Can anyone see where I am going wrong?
Thanks
"$currentslots"outside the query i.e. first count the exiting one's and then add 1 to it. Also, the correct format would be".$currentslots.""normal text $variable more normal text"$currentslotsis a resource variable, you would have to get the number of rows first.