Jump to content

Testing against a date...*SOLVED*


pocobueno1388

Recommended Posts

Thanks to everyone who helped me with my last question, but after I fixed that I ran into another problem with the date, I am not very good at all with working with dates in PHP.

What my script does is when a user clicks a button which holds an ID of a dog, it will breed the dog and insert a date into the database which is 7 days from the date they just clicked the button.

What I want to do is next time they click the button to breed the dog is test whether the date in the database (which holds the date 7 days after they clicked last time) is either equal to todays date or if the current date has not reached the date in the database. If this is true it will display an error saying "You have already bred this dog in the last 7 days!".

I have tried doing this myself but it always displays the error message "You have already bred this dog in the last 7 days!"  whether it has been 7 days or not.
Here is my attempted code:

[code]
$today = date ('Y/m/d', strtotime ("U"));

if ($row3['next_breed'] < $today){
echo "<table class='main'><td class='main'>You must wait a week to breed this female again!<p>
She may be bred again on $row3[next_breed]</td></table>";
exit;
}
[/code]

$row3['next_breed'] is what holds the date +7 days from when they clicked the button last.

I am not sure if the default 'Date' in the database will effect anything. If they have never clicked the button the default date is obviously 0000-00-00, but I don't think that is the problem...it may be though.

Let me know what you guys think =) Thanks.

All help is greatly appreciated xP
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.