archiving news items

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

archiving news items

Post by hame22 »

Hi

I have got a collection of news articles held in a database that I wish to archive.

What I want to do is to display groups of articles as to the month and year that they were published,

e.g. Jan 2004 Articles, Feb 2004 Articles etc

I want this to be on going for the future so it can maintain itself,

I was wonderingif anyone knew how to do this or any scripts available?

Thanks
foobar
Forum Regular
Posts: 613
Joined: Wed Sep 28, 2005 10:08 am

Post by foobar »

That depends what your database looks like. Can you dump the create statements for your tables and post them here? Otherwise, there's little I can do to help you.
markg85
Forum Commoner
Posts: 32
Joined: Sat Dec 03, 2005 6:49 pm

Post by markg85 »

well.. there must exists scripts like that on http://www.hotscripts.com/PHP/Scripts_a ... index.html (hotscripts) but the bad thing about that is that those functions will most likely be hard coded in the script and not easy o get them out...

and besides that.. i`m also looking for a easy way to do this :)
hame22
Forum Contributor
Posts: 214
Joined: Wed May 11, 2005 5:50 am

Post by hame22 »

Code: Select all

CREATE TABLE `rss` (
  `rss_id` int(50) NOT NULL auto_increment,
  `headline` varchar(255) NOT NULL default '',
  `content` text NOT NULL,
  `news_url` varchar(255) NOT NULL default '',
  `pub_date` date NOT NULL default '0000-00-00',
  `image` varchar(255) NOT NULL default '',
  PRIMARY KEY  (`rss_id`)
) TYPE=MyISAM AUTO_INCREMENT=21 ;
is that what you wanted?

thanks
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

Well .. to get all the articles published in (for example) Feb 2005 ..

Code: Select all

select * from rss where MONTH(pub_date) = 2 and YEAR(pub_date) = 2005
That's all you need to know..
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

make use of the date (and it's children) syntax in your select statements.

http://dev.mysql.com/doc/refman/5.0/en/ ... tions.html
Post Reply