JohnnyBoy928 Posted March 17, 2011 Share Posted March 17, 2011 I have this simple news article program I have been working on... Works great for the most part but I have a question I keep stumbling on being fairly new at php... This code below pulls articles from a summary data file (article_summary.html) and it includes the latest xx amount of articles I declare in the conf file... I need the conf file for other various items but I still want to keep the count of how many are displayed/pulled... What I am having issues with is adding a date and more specifically a year... I would like to show xx amount of the latest articles from the year 2010 for instance... (i.e. The latest 100 articles from year 2010)... Right now this shows the latest 100 from current day to previous... Thanks in advance for any help... main code that calls articles (I need to add date/year filter somehow) <? require('config.php'); $filename = "article_summary.html"; #- open article summaries if(file_exists($filename)){ $fh = fopen($filename, "r"); $old_news = fread($fh, filesize($filename)); fclose($fh); } #- get first five article $articles = explode("<!--ARTICLE-->", $old_news); $i=0; foreach ( $articles as $article ){ if(count($articles)>$i){ if($max_latest >= $i++){ print $article; } } } ?> config.php <? $summary_template = "t_summary.html"; $article_template = "t_article.html"; $max_summary = 100; $max_latest = 100; $password = "xxxxx"; ?> This code is from the article_summary.html and the date is in the filename of the link... This is where I keep having sytax issue with my coding... <!--ARTICLE--> <b><a href=http://www.mydomain.com/articles/gaming/article_GAMING_2010_08_1_4459.html>Proposed Merger of PartyGaming and bwin Interactive Entertainment </a></b><br /> <div align="justify">Creation of the world’s largest listed online gaming business</div> <!--ARTICLE--> <b><a href=http://www.mydomain.com/articles/gaming/article_GAMING_2010_05_21_4723.html>Lawmakers consider Internet gambling bills</a></b><br /> <div align="justify">Internet gambling should be legalized and taxed in the United States to raise billion in revenue over a decade and legitimize gamers who bet online, </div> <!--ARTICLE--> <b><a href=http://www.mydomain.com/articles/gaming/article_GAMING_2010_03_16_3434.html>Las Vegas, Nevada is preparing for legal online casino gambling within the United States.</a></b><br /> <div align="justify">Known as the capital of land-based gambling in the US, they want to get a fresh start with online gambling once it becomes legal on a federal level. </div> Link to comment https://forums.phpfreaks.com/topic/230919-pulling-data-from-a-file-using-a-date-range/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.