scorptique
12-06-2008, 03:25 PM
Hello again guys, I need some help here.
I have a list of contact details, which includes their birthdays. If user clicks the link "Sort by birthday", the url will become contacts.php?category=cl_dob. So I use the GET method and put it in $category. How do I sort the contacts by the upcoming birthdays? Means the contact with the nearest birthday will be at the top.
I tried this but it didnt work. Help guys.
if ($category == 'cl_dob')
{
$sql = "select cl_id, cl_fname, cl_lname, cl_email, date_format(cl_dob, '%d %b %Y') AS cl_dob from contact_list
where username = '$username'
AND DATE_FORMAT('cl_dob', '%m-%d') > DATE_FORMAT(NOW(), '%m-%d')
ORDER BY cl_dob DESC ";
}
I have a list of contact details, which includes their birthdays. If user clicks the link "Sort by birthday", the url will become contacts.php?category=cl_dob. So I use the GET method and put it in $category. How do I sort the contacts by the upcoming birthdays? Means the contact with the nearest birthday will be at the top.
I tried this but it didnt work. Help guys.
if ($category == 'cl_dob')
{
$sql = "select cl_id, cl_fname, cl_lname, cl_email, date_format(cl_dob, '%d %b %Y') AS cl_dob from contact_list
where username = '$username'
AND DATE_FORMAT('cl_dob', '%m-%d') > DATE_FORMAT(NOW(), '%m-%d')
ORDER BY cl_dob DESC ";
}