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 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 a count of how many are displayed…
What I am having issues with is adding a date and more specifically a year… I would like to show xx amount of 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… I know I have to declare a date variable but my syntax keeps faulting…
Like I said, i’m a noob…
[php]<?
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 X articles
$articles = explode("<!--ARTICLE-->", $old_news);
$i=0;
foreach ( $articles as $article ){
if(count($articles)>$i){
if($max_latest >= $i++){
print $article;
}
}
}
?>[/php]
CONFIG.PHP[php]<?
$summary_template = “t_summary.html”;
$article_template = “t_article.html”;
$max_summary = 100;
$max_latest = 100; $password = “xxxxxx”;
?>
[/php]