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. Link to comment https://forums.phpfreaks.com/topic/169838-how-to-insert-articles-but-only-some/ 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? Link to comment https://forums.phpfreaks.com/topic/169838-how-to-insert-articles-but-only-some/#findComment-896018 Share on other sites More sharing options...
UziLok Posted August 11, 2009 Share Posted August 11, 2009 You should consider using php tags Link to comment https://forums.phpfreaks.com/topic/169838-how-to-insert-articles-but-only-some/#findComment-896022 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] Link to comment https://forums.phpfreaks.com/topic/169838-how-to-insert-articles-but-only-some/#findComment-896029 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. Link to comment https://forums.phpfreaks.com/topic/169838-how-to-insert-articles-but-only-some/#findComment-896043 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.