Just display the month?

This is a discussion on "Just display the month?" within the PHP Forum section. This forum, and the thread "Just display the month? are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Feb 3rd, 2008, 10:38
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Just display the month?

I've been working on adding a breadcrumb to my site - you can see it in action right now if you check it out. At the moment it is 'Home>Category>Post'. How can I find out the month of the post, so I can have it like: 'Home>Month>Category>Post'

Thanks, and I apologise for yet another question! This is the PHP code that selects the stuff from the database and displays the bread crumb.


PHP: Select all

$display_posts = @mysql_query("SELECT contentid, contenttitle, contentintro, content, author, category, views, date_format(date, '%M %D, %Y') AS date FROM content WHERE contentid='$contentid'");
if(!
$display_posts) {
echo 
'<h4>Error Displaying Comments.' mysql_error() . '</h4>';
}
while (
$posts mysql_fetch_array($display_posts)) {
$contentid $posts['contentid'];
$contenttitle $posts['contenttitle'];
$contentintro $posts['contentintro'];
$content $posts['content'];
$author $posts['author'];
$category $posts['category'];
$date $posts['date'];
//display
echo '<p id="youareheretext">You are here: <span id="youarehere"><a href="index.php">Home</a> :: <a href="category.php?category.php?category=' $category '">' $category '</a> :: <a href="single.php?contentid=' $contentid '">' $contenttitle '</a></span></p>'
I think it will use
PHP: Select all

MONTH(date
somewhere, but I'm not sure where.

Thanks,

Jack
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Reply With Quote

  #2 (permalink)  
Old Feb 3rd, 2008, 12:53
Marc's Avatar
Moderator

SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Age: 15
Posts: 1,650
Thanks: 0
Thanked 8 Times in 8 Posts
Send a message via MSN to Marc Send a message via Skype™ to Marc
Re: Just display the month?

Just change:
date_format(date, '%M %D, %Y') AS date to date_format(date, '%M') AS date..

Will that not work?
Reply With Quote
  #3 (permalink)  
Old Feb 3rd, 2008, 12:59
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: Just display the month?

Yes, but I want to display the Main date (22nd January 2008) AND use the month on the same page. If you look here: http://jackfranklin.co.uk/single.php?contentid=29 You can see the breadcrumb at the top, I want the Month to display here, but you can also see the date next to the Post title. I need to display both. Could I do this?
PHP: Select all

display_posts = @mysql_query("SELECT contentid, contenttitle, contentintro, content, author, category, views, date_format(date, '%M %D, %Y') AS date, date_format(date, '%M') AS month 

Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Reply With Quote
  #4 (permalink)  
Old Feb 3rd, 2008, 13:06
Marc's Avatar
Moderator

SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Age: 15
Posts: 1,650
Thanks: 0
Thanked 8 Times in 8 Posts
Send a message via MSN to Marc Send a message via Skype™ to Marc
Re: Just display the month?

try it, it might
Reply With Quote
  #5 (permalink)  
Old Feb 3rd, 2008, 13:10
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: Just display the month?

Will do and I shall get back to ya
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Reply With Quote
  #6 (permalink)  
Old Feb 3rd, 2008, 13:21
Jack Franklin's Avatar
Resources Administrator

SuperMember
Join Date: May 2007
Location: Cornwall, England
Posts: 1,268
Blog Entries: 7
Thanks: 10
Thanked 4 Times in 4 Posts
Re: Just display the month?

WORKED ! Check out http://www.jackfranklin.co.uk/single.php?contentid=20 to see the result, in the breadcrumb bit. If you would like to see the code just ask.
Last Blog Entry: My Latest Project - Grilling Gurus... (Jun 11th, 2008)
Reply With Quote
  #7 (permalink)  
Old Feb 3rd, 2008, 13:24
Marc's Avatar
Moderator

SuperMember
Join Date: Apr 2007
Location: Scotland, UK
Age: 15
Posts: 1,650
Thanks: 0
Thanked 8 Times in 8 Posts
Send a message via MSN to Marc Send a message via Skype™ to Marc
Re: Just display the month?

Good work!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Month and Year Jenstina Databases 1 Jun 26th, 2006 20:01
Site of the Month craig Entry, Nominations and Voting 0 Oct 18th, 2005 12:19


All times are GMT. The time now is 20:56.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43