WordPress.org

Support

Support » Plugins and Hacks » Hacks » How to list the names of people celebrating their birthday today

How to list the names of people celebrating their birthday today

  • Hello,

    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Solved…

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

    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.

    regards

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to list the names of people celebrating their birthday today’ is closed to new replies.
Skip to toolbar