Hi I have a script that manages some articles. The script shows the last 3 articles using the following code: In config file: $max_latest = 3; And in another file: <? 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 five article $articles = explode("<!--ARTICLE-->", $old_news); $i=0; foreach ( $articles as $article ){ if(count($articles)>$i){ if($max_latest >= $i++){ print $article; } } } ?> My question is: How do I get it to ONLY show articles 4-8??? Is there a simple code to add? Can you write that code for me? whats the price?? Thx t
$articles = explode("<!--ARTICLE-->", $old_news); $countarticles = count($articles); if ($countarticles >= 4) { if ($countarticles > = 8) { $lastarticle = 8; } else { $lastarticle = $countarticles; } for ($i=3; $i<=$lastarticle; $i++) { print $article[$i]; } }
Hey! Thanks mate! That was quick! Im to dum to get that to work.. I get a foult on line 9.. should I add something to the config file too? How about I send the files over to you and you add it in there nicely, and I pay you with paypal Drop me a PM. Thx again for your time. T
<?php $filename = "article_summary.html"; #- open article summaries if(file_exists($filename)){ $fh = fopen($filename, "r"); $old_news = fread($fh, filesize($filename)); fclose($fh); } $articles = explode("<!--ARTICLE-->", $old_news); $countarticles = count($articles); if ($countarticles >= 4) { if ($countarticles >= 8) { $lastarticle = 8; } else { $lastarticle = $countarticles; } // If "<!--ARTICLE--> is present at the top of the article, then make $i=4 in the below line for ($i=3; $i<=$lastarticle; $i++) { print $articles[$i]; } } ?> PHP: This will work!