hello,
i want to display names of upcoming birthdays whose between "today" to "end of every month". how to do this

Recommended Answers

All 8 Replies

hello,
i want to display names of upcoming birthdays whose between "today" to "end of every month". how to do this

how to retrive values from database

how to retrive values from database

assuming u have a field dob (with datatype as date) in user table this query can help u...

$current_month = date(m);
 $current_day = date(d);
    $result = mysql_query("SELECT name FROM user WHERE month(dob) = $current_month AND day(dob) >= $current_day ")

Hope its clear..
cheers!!

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND day(dateofbirth) >=' at line 1

getting this error

$result = mysql_query("SELECT name FROM user WHERE month(dob) = '$current_month' AND day(dob) >= '$current_day' ")
$result = mysql_query("SELECT name FROM user WHERE month(dob) = '$current_month' AND day(dob) >= '$current_day' ")

yeah try that out... my bad... rightly deserve a negative point for that post :(
Actually u should alwayz save ur query in a variable and then execute it..
this way when u encounter an error , u can echo ur query statement and find out the source of error easily...
something like this..

$query = "SELECT name FROM user WHERE month(dob) = ".$current_month." AND day(dob) >= ".$current_day;
$result = mysql_query($query);

yeah try that out... my bad... rightly deserve a negative point for that post :(
Actually u should alwayz save ur query in a variable and then execute it..
this way when u encounter an error , u can echo ur query statement and find out the source of error easily...
something like this..

$query = "SELECT name FROM user WHERE month(dob) = ".$current_month." AND day(dob) >= ".$current_day;
$result = mysql_query($query);

how to fetch date as this format: (example: 2nd aug 1986) like this
how to format?

i want to display date format this (1989-03-09) as 9th mar 1989.
give an idea......how to format like this

i want to display date format this (1989-03-09) as 9th mar 1989.
give an idea......how to format like this

use this query..

$query = "SELECT name, DATE_FORMAT(dob, '%D %b %Y') FROM user WHERE month(dob) = ".$current_month." AND day(dob) >= ".$current_day;

I guess this is what u r lookin for...
Cheers!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.