How to list the names of people celebrating their birthday today (3 posts)

  1. vicencianos
    Posted 5 years ago #


    I have very little knowledge of PHP...

    I am trying to echo a plain list of my friends' names whose birthday is "today" in my sidebar.
    I have already created and filled the SQL database [named birthdays] for them, with 3 fields:
    - day
    - month
    - name
    And filled it with the data.

    Ok, so I would want to have an output like "Today's birthday: John – Mary – Simon."
    I have made the following query to the database:

    <?php $names = $wpdb->get_results("SELECT name FROM $wpdb->birthdays
    WHERE day = date(j) AND month = month(n)");

    <?php foreach ($names as $thename) {
    echo $thename->name;
    echo " – ";

    ...but nothing shows up and I don't know why.

    If you could help me... Thanks.

  2. vicencianos
    Posted 5 years ago #


    error in the first line, should be:
    <?php $names = $wpdb->get_results("SELECT name FROM birthdays

  3. Prince Abiola Ogundipe
    Posted 5 years ago #

    hi vicencianos, glad you get this working. please can you tell me which file did you add this code? i want to have list of members which birthdays is today on a page. i have birthday field in my register.


Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.