Jump to content

I need help to archive a month old news


shahzad

Recommended Posts

in my website there is news scrolling panel where what ever the new inserted in database scrolls.

 

but what i need now that only fresh or current month news will scroll and old news will archived

where i can display it in archive page in monthly or yearly view.

 

 

is it possible if yes what will be the logic or working behind it.

 

 

Thanks in advance

 

Thanks & Best regards,

Shahzad Ahmed

Link to comment
Share on other sites

You will need to be more specific. Post your current code and explain which available columns exist in your database. For example, is there a "date" column in your database that you can use to sort the news by date? Are you currently even using a database and PHP?

Link to comment
Share on other sites

You will need to be more specific. Post your current code and explain which available columns exist in your database. For example, is there a "date" column in your database that you can use to sort the news by date? Are you currently even using a database and PHP?

 

my website address is http://www.omegadubai.com/

on left side you can see news scrolling panel.

link to news detail page

http://www.omegadubai.com/News_Detail.php?Pageid=5

 

yes i am using MySql as database

Tablename : tablenews

fields

TableID

Date

NewsScroll

NewsTitle

NewsDescription

Image

Link

PDF

 

 

thanks for your time bro

Link to comment
Share on other sites

Show us the query that is currently used to pull the records for the scrolling panel. Also, what "type" of field is the date field? Is it a date, datetime, or timestamp field? You will just need to modify that query to add a where clause to filter the results for records that are newer than 1 month (or whatever period you want).

 

Example:

SELECT *
FROM `table`
WHERE `Date` > $timestampOneMonthBack

Link to comment
Share on other sites

the query for scrolling is following but i am just scrolling date with short news.

$querynews="select * from tablenews";

 

 

ok i got an idea now how to control news to diplay current month news..

 

but what about archive now

clients wants when he will click News Archive

a list of months and years appears which have news appear so that users can click and view all the news for that following month..

 

 

Link to comment
Share on other sites

the query for scrolling is following but i am just scrolling date with short news.

$querynews="select * from tablenews";

 

 

ok i got an idea now how to control news to diplay current month news..

 

but what about archive now

clients wants when he will click News Archive

a list of months and years appears which have news appear so that users can click and view all the news for that following month..

 

You would do the same thing to look at acrchived news - just set an appropriate WHERE clause for the time period you need. You didn't state what the format of the field is in the database, but if it is datetime or a timestamp (and not simply a date field) then you need to ensure the timestamps you create for the queries are at midnight of the start of the search day or midnight at the end of the search day as appropriate.

 

For example if trying to find all the articles in Dec. you would want the start timestamp to be at 00:00:00 on Dec  1st. (i.e. midnight between Nov. 30th and Dec 1st.) and the end timestamp would be at 24:00:00 on Dec. 31st (i.e. midnight between Dec 31st. and Jan. 1st.). Then just create your query like so:

 

SELECT *
FROM `tablenews`
WHERE `Date` > $startTimestamp
  AND `Date` > $endTimestamp

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.