Working With Time
Posted: Sun Sep 15, 2013 12:09 am
Okay all... I use this formula to determine how many times a person has been attacked/robbed within a 24 hour time period, and if they have been attacked so many times, there is no attack button on them so that nobody can attack them.
What I would like to do is show a list of your previous attackers for the day, but I'm having much trouble trying to figure it out, since the logs only show the id's of the attacker and the one that was attacked. The usernames are in the user table, while the logs show the time, attacker, the defender. I've tried to run a loop, but ran into problems where it showed all the logs information instead of the information needed only for one specific user session. Below I have the tables and the infomation:
Table that holds the users information is User
Table that holds the person attacked and the attackers / time information is Logs
*NOTE* the ID's are not the same in the tables.
My problems been trying to pull the attacker out of the database, line it up with the users table username, and then make it specific for each player to see their own last attackers.
And would also like to display how many mins/seconds are left before they can be hit again...
Any Idears? Thank you!
Code: Select all
$attacks_check = mysql_query("SELECT `id` FROM `logs` WHERE `attacker`='".$_SESSION['uid']."' AND `guards`='".$id."' AND `time`>'".(time() - 86400)."'") or die(mysql_error());
Table that holds the users information is User
Code: Select all
id
username
Code: Select all
id
attacker - Person that attacked another person
guards - Person that was attacked
time - Time they were attacked
My problems been trying to pull the attacker out of the database, line it up with the users table username, and then make it specific for each player to see their own last attackers.
And would also like to display how many mins/seconds are left before they can be hit again...
Any Idears? Thank you!