Re: mysql php - help needed
This should work, I believe:
SELECT * FROM table WHERE MONTH(date_of_birth) = MONTH(CURDATE()) AND DAY(date_of_birth) = DAY(CURDATE()) AND email NOT NULL AND email !='';
Edit for less processing overhead:
SELECT * FROM table WHERE DATEFORMAT(date_of_birth, '%c %e') = DATEFORMAT(CURDATE(), '%c %e') AND email NOT NULL AND email !='';
You could go even easier, if there is a large database, and replace the second DATEFORMAT() with a PHP variable containing the current date and month, separated by a space.
__________________
The best way to learn anything, is to question everything.
Last edited by wige : 03-12-2008 at 09:18 AM.
|