shahzad Posted January 25, 2010 Share Posted January 25, 2010 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 Quote Link to comment Share on other sites More sharing options...
Irap Posted January 25, 2010 Share Posted January 25, 2010 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? Quote Link to comment Share on other sites More sharing options...
shahzad Posted January 25, 2010 Author Share Posted January 25, 2010 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 Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 25, 2010 Share Posted January 25, 2010 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 Quote Link to comment Share on other sites More sharing options...
shahzad Posted January 25, 2010 Author Share Posted January 25, 2010 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.. Quote Link to comment Share on other sites More sharing options...
jamiet757 Posted January 25, 2010 Share Posted January 25, 2010 add this to the end: WHERE `Date` > $timestampOneMonthBack so you get: $querynews="select * from tablenews WHERE `Date` > $timestampOneMonthBack"; Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 25, 2010 Share Posted January 25, 2010 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 Quote Link to comment Share on other sites More sharing options...
shahzad Posted January 26, 2010 Author Share Posted January 26, 2010 Ok thankyou very much got it... Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 26, 2010 Share Posted January 26, 2010 Whoops! That query should have had a less than instead of a greater than on the last line. But, I think you got the idea. Quote Link to comment Share on other sites More sharing options...
shahzad Posted January 26, 2010 Author Share Posted January 26, 2010 hahaha yes yes i got an idea thanks your help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.