/    Sign up×
Community /Pin to ProfileBookmark

Displaying the month as a month…

Hello people…

Just a quick one to pick your minds, i know this isnt too complex but i just cant get a solution.

Anyway. Using php and mysql i have a simple table of upcoming events.
These events are stored nicely and the date is in the proper date field (0000 00 00)

When the website user visits my page they simply have to enter a month to have displayed everything that is going on in that month in ascending order.

The query i am using (which seems to works ok) is this.

[code=php]
$SQL = “SELECT name, DATE_FORMAT(date,’%D %M %Y’) AS print_date, location, telephone, email, extra, description FROM events WHERE MONTH(date) = ‘$month’ AND date >=CURDATE() ORDER BY date ASC LIMIT 100”;
$result = mysql_query( $SQL );
while( $row = mysql_fetch_array( $result ) ) {
$name = $row[“name”];
$date = $row[“print_date”];
$location = $row[“location”];
$telephone = $row[“telephone”];
$email = $row[“email”];
$extra = $row[“extra”];
$description = $row[“description”];
?>[/code]

Now my query is this, when the user has entered the month they desire and hit submit on the page that comes from the above query along with the actual results i would like to have a quick note just stating that a certain month is being displayed.

i.e Upcoming event for month (jan, feb, marc, etc.etc)

Now if i put in a simple

[code=php]<?php echo $month;?>[/code]

then it will be displayed as a number 01,02,03 — 12. As this is how it is stored in mysql.

So my question is how can i have this displyed again as a real date.
I know this is blindingly obvious as i can display the full date through the above query ok, but to display just the month as a month is a pain for me.

thanks in advance for any replies.

Bolty2uk

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@NogDogDec 17.2006 — One way would be:
[code=php]
echo date('F', mktime(0,0,0,$month));
[/code]
Copy linkTweet thisAlerts:
@JayMDec 17.2006 — [code=php]
select ($month)
{
case '01': echo "January";
break;
case '02': echo "February";
break;
}
[/code]
Copy linkTweet thisAlerts:
@NightShift58Dec 17.2006 — Question: Why this way instead of NogDog's?
Copy linkTweet thisAlerts:
@JayMDec 18.2006 — NogDog's way is definitely more efficient. Bolty2k was saying he/she couldn't think of how to do this, so it's always a good idea to suggest several ways. That way Bolt as well as other users can learn different approaches to a problem, and be able to use it in future troubleshoots.
Copy linkTweet thisAlerts:
@bolty2ukauthorDec 18.2006 — Thanks NogDog.

Your input worked perfectly.. I just couldnt get my head around this one.

Also thanks for your input JayM, as you rightly say it is also good to get a good idea of the different ways so as to get an idea of the different solutions.

I also find that to actually undestand what the code is actually doing is far more benificial than simply copy/pasting code in to the script..

thanks chaps..

Bolty2uk
×

Success!

Help @bolty2uk spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.1,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...