Jump to content

How to insert articles (but only some)?


ninevolt1

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.