SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Threaded View

  1. #1
    SitePoint Evangelist spoondevil's Avatar
    Join Date
    Jun 2001
    Harlow, Essex, UK
    0 Post(s)
    0 Thread(s)

    Show Next Birthday - PHP & MySQL

    My site contains a database of a group of friends, all with profiles and their date of birth entered. I need a query to show when the next birthday & the date it is, also how old they will be.

    Next Birthday: Ian Gunter will be 28 on the 11th July

    I have come up with this
    SELECT id, name_f, name_l, DATE_FORMAT(d_o_b,'%m %D') AS d_o_b2
    FROM users
    WHERE d_o_b <=CURDATE()
    ORDER BY d_o_b2 ASC
    LIMIT 0,1
    This selects the first birthday that happens that year, I need it to somehow reference today date and sort from there, but when I use the d_o_b2 field name in the WHERE clause, I get error # 1054 (unknown column).

    I also can't figure out ho to use the year to work out how old they will be.

    Any ideas?
    Last edited by spoondevil; May 31, 2004 at 16:04.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts