-1

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

Edited by muralikalpana: n/a

3
Contributors
8
Replies
9
Views
7 Years
Discussion Span
Last Post by venkat0904
0

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

-1

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!!

Edited by venkat0904: n/a

0
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

0
$result = mysql_query("SELECT name FROM user WHERE month(dob) = '$current_month' AND day(dob) >= '$current_day' ")
1
$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);

Edited by venkat0904: improvising

-1

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?

-1

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

0

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!!

Edited by venkat0904: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.