Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
if statement with dates
Old 05-01-2008, 04:55 AM if statement with dates
Junior Talker

Posts: 3
Trades: 0
hello, im using a delete function but some how i want to use an if statement; for example if the current server date matches the date from a row from a database table and if the date is 2days from the current date it can't be delete.
panther786 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 05-02-2008, 11:13 AM Re: if statement with dates
addonchat's Avatar
Super Talker

Posts: 115
Name: Chris Duerr
Trades: 0
Sounds like it's just a SQL issue, not a PHP issue. Check out:
http://dev.mysql.com/doc/refman/4.1/...functions.html

The first example (the SELECT example) should give you all that you need -- You'll basically just be changing the interval (from 30 days to 2 days), the column name, and using DELETE instead of SELECT
__________________
Chris Duerr
AddonChat Java Chat Software

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
addonchat is offline
Reply With Quote
View Public Profile
 
Old 05-02-2008, 11:54 AM Re: if statement with dates
Plugin-Developer's Avatar
Weightlifting CS Student

Posts: 504
Name: Nick Ohrn
Trades: 0
panther786 - I'm not entirely sure I understand your question, but I'll try to give you an answer.

It looks like you're trying to not delete a record if the day is within two days of the current date. Assuming that is the case, you just need to calculate the time difference between the record being deleted and the current time. To do so, you can just implement a time_difference function and check out the value to see if it is less then a certain amount. See the php time function page and search for difference. As the other poster said, you can also do this in SQL, but I didn't know if you had a reason for not wanting to do it that way.
__________________

Please login or register to view this content. Registration is FREE
- Custom plugin development to fit your needs. Plugins available for WordPress and Drupal, among others.
Plugin-Developer is offline
Reply With Quote
View Public Profile Visit Plugin-Developer's homepage!
 
Reply     « Reply to if statement with dates
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.23484 seconds with 12 queries