How to find BIRTHDAY FRIENDS Who is celebrating today using PHP and MYSQL

How to find BIRTHDAY FRIENDS Who is celebrating today using PHP and MYSQL

thanks in Advance ...

Feraud

-3


source to share


4 answers


This person is processing February 29 - March 1 treatment as a holiday during off-peak years.

SELECT u.name
FROM users u INNER JOIN friendships f ON (f.user_id = u.id)
WHERE f.friend_id = 6 -- whatever your id is
    AND (
        MONTH(u.birthdate) = MONTH(NOW())
        AND DAY(u.birthdate) = DAY(NOW())
    ) OR (
        MONTH(c.birthdate) = 2 AND DAY(c.birthdate) = 29
        AND MONTH(NOW()) = 3 AND DAY(NOW()) = 1
        AND (YEAR(NOW()) % 4 = 0)
        AND ((YEAR(NOW()) % 100 != 0) OR (YEAR(NOW()) % 400 = 0))
    )

      



Without seeing your table structure, I was just guessing how you handle friendship links

+8


source


You can combine the cURL calls to http://www.birthdatabase.com in your application and read the HTML in the results.



Edit . I may have misunderstood your question. If you are trying to pull birthdays from a different database (not yours) this might be your solution.

0


source


Make separate fields for month and day to make your selection faster.

0


source


Thanks everyone

I got an answer ...

SELECT * FROM `users` WHERE MONTH(`birthdate`) = MONTH(NOW()) AND
     DAYOFMONTH(`birthdate`) = DAYOFMONTH(NOW());

      

Using this request, we can get the data we need

Feraud

-3


source







All Articles