PDA

View Full Version : Best Way To Show Month


tomyknoker
04-17-2007, 04:11 PM
I have this script

$date = date('d/m/Y');
$month = date('m');

if ($month == "12") {
$theMonth = "01";
}

else {
$theMonth = $month+1;
}

My Query
$query = "SELECT tblmembers.*
, tblrepresentatives.rep_Firstname
, tblrepresentatives.rep_Lastname
FROM tblmembers
LEFT OUTER
JOIN tblrepresentatives
ON tblrepresentatives.rep_NBR = tblmembers.rep_NBR
WHERE MONTH(tblmembers.DateOfBirth) = $theMonth
AND tblmembers.MemberApproved = 'A' ORDER BY LastName";

And then it outputs to this

The following members are Celebrating Birthdays in $theMonth.

At the moment it just outputs the month as a number, do I need to set up 12 sepearate if statements, to get the numbers to be converted to text?

mlseim
04-17-2007, 04:20 PM
See this:
http://us2.php.net/date

Use a capital "M" or capital "F"

david_kw
04-17-2007, 04:42 PM
I suspect you will also need

http://us2.php.net/manual/en/function.mktime.php

so the code might look something like


$timestamp = mktime(1, 1, 1, $theMonth, 1);
$month_name = date("F", $timestamp);


Only semi-tested.

david_kw