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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.