| | |
birthday reminder
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
php Syntax (Toggle Plain Text)
$query = sprintf("UPDATE TABLE SET birthday = %s", strtotime($birthday));
Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
•
•
•
•
Hope something like this will work perfectly!! any more ideas or suggestions, really appreciate folks:
but they dont keep bolting new bits on it to make it useable
they mothballed it in a museum and build jumbo jets
biggerthis is a hint
faster
able to move hundreds of people
thousands of times further and
hundred times faster than the original plane
ditch the biplane
build a jumbo
There would be less work in redoing the code, than always repairing it.
What about the next time you wish to add a feature.
it is real easy in timestamps to add StUfF,
"who's online"
"popular pages"
"most recently viewed'
without doing much programming work.
Failure is not an option It's included free, you don't have to do anything to get it
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
If at first you dont succeed, join the club
Of course its always in the last place you look, you dont keep looking after you find it
Please mark solved problems, solved
•
•
Join Date: Nov 2009
Posts: 2
Reputation:
Solved Threads: 0
I have stored the birthdates in the db in a YYYY-MM-DD format (just string) and want to get all birthdays from now to 7 days ahead.
Timestamps are no option as far as i know (see above post).
Here I found the solution to get it all by only using a MySQL-query:
This works simply and beautifully, without any heavy php-parsing.
I am so happy!
Timestamps are no option as far as i know (see above post).
Here I found the solution to get it all by only using a MySQL-query:
PHP Syntax (Toggle Plain Text)
SELECT * FROM `members` WHERE DATE_FORMAT(`dateofbirth`, '%m%d') >= DATE_FORMAT(NOW(), '%m%d') AND DATE_FORMAT(`dateofbirth`, '%m%d') <= DATE_FORMAT(DATE_ADD(NOW(), INTERVAL 7 DAY), '%m%d') ORDER BY DATE_FORMAT(`dateofbirth`, '%m%d') ASC
I am so happy!
0
#16 Nov 3rd, 2009
•
•
•
•
I have stored the birthdates in the db in a YYYY-MM-DD format (just string) and want to get all birthdays from now to 7 days ahead.
Timestamps are no option as far as i know (see above post).
Here I found the solution to get it all by only using a MySQL-query:
This works simply and beautifully, without any heavy php-parsing.PHP Syntax (Toggle Plain Text)
SELECT * FROM `members` WHERE DATE_FORMAT(`dateofbirth`, '%m%d') >= DATE_FORMAT(NOW(), '%m%d') AND DATE_FORMAT(`dateofbirth`, '%m%d') <= DATE_FORMAT(DATE_ADD(NOW(), INTERVAL 7 DAY), '%m%d') ORDER BY DATE_FORMAT(`dateofbirth`, '%m%d') ASC
I am so happy!
That way you can use the indexes on the INT columns, just as you would a timestamp, but allow any range of dates.
An example of a date range query, for birthdays within today (November 3rd) and the next 7 days.
sql Syntax (Toggle Plain Text)
SELECT * FROM users WHERE YEAR = 2009 AND MONTH = 11 AND DAY >= 3 AND DAY <= 9
or for two overlapping months, such as last week:
sql Syntax (Toggle Plain Text)
SELECT * FROM `users` WHERE (YEAR = 2009 AND MONTH = 10 AND DAY >=27) OR (YEAR = 2009 AND MONTH = 11 AND DAY <= 3)
A few things need to be calculated on the PHP side though, such as the number of days in the month and the overlaps between months. I wrote a class to handle this: http://code.google.com/p/php-calendar-class/
That would be more efficient then DATE_FORMAT() which does not make use of indexes.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
![]() |
Similar Threads
- Do I need to use strotime for making a birthday notification. (PHP)
- Help with automatic update problem and more (Viruses, Spyware and other Nasties)
- reminder pop up (Visual Basic 4 / 5 / 6)
- BCC: Multiple Recipient (PHP)
- Saxto.com and saxor.com for sale (Domain Names for Sale)
- Using HTML tags in PHP code (PHP)
- ¶Happy Birthday........ (Geeks' Lounge)
- Various websites for sale (music, investing, online magazines, etc) (Websites for Sale)
Other Threads in the PHP Forum
- Previous Thread: Deleting rows
- Next Thread: Suggestions on X-cart opensource ?
Views: 1914 | Replies: 15
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery js limit link login loop mail mediawiki menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search select server sessions sms soap source space speed sql stored structure subdomain syntax system table tutorial update updates upload url validation validator variable video web xml youtube






