ninevolt1 Posted August 11, 2009 Share Posted August 11, 2009 I have this small PHP script on my page that pulls news articles from an html file. I want to modify it so that it only pulls articles #6 and on (basically ignore the first 5 articles). The PHP code looks like this: <?php require('news_manager/config.php'); $filename = "news_manager/article_summary2.html"; #- open article summaries if(file_exists($filename)){ $fh = fopen($filename, "r"); $old_news = fread($fh, filesize($filename)); fclose($fh); } #- get articles $articles = explode("<!--ARTICLE-->", $old_news); $i=0; foreach ( $articles as $article ){ if(count($articles)>$i){ if($max_latest >= $i++){ print $article; } } } ?> The config.php file that it references looks like this: <? $max_summary = 5; $max_latest = 20; ?> Thanks for any help on this. I figure it's just a couple lines of code but I am not very proficient in PHP and just hack my way around. I haven't been able to figure this one out. Quote Link to comment Share on other sites More sharing options...
br3nn4n Posted August 11, 2009 Share Posted August 11, 2009 And what happens when you try to run the script? Quote Link to comment Share on other sites More sharing options...
UziLok Posted August 11, 2009 Share Posted August 11, 2009 You should consider using php tags Quote Link to comment Share on other sites More sharing options...
br3nn4n Posted August 11, 2009 Share Posted August 11, 2009 You should consider using php tags For reference, just like any other bbcode tag: [code=php:0]Your code here... [/code] Quote Link to comment Share on other sites More sharing options...
ninevolt1 Posted August 11, 2009 Author Share Posted August 11, 2009 And what happens when you try to run the script? It runs fine as it is. But it was made just to retrieve my news articles. But if you read above, I want to modify it per the criteria I wrote above. 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.