Jump to content

Archived

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

moOt

Simple file Display Script

Recommended Posts

Hey All,

I am kind of new to PHP and I dont even know where to begin for a script that I need to make. I checked the posting guidelines and I made sure to check for tutorials or premade scripts but there are so many different script sections I dont know where to even begin, its overwhelming!

Well anyway, Im looking to create my own script very similar to the headlines script seen in many of the News Publishing PHP scripts. I basically want to put links to a bunch of word, picture and powerpoint files in the top of a text file. After I have updated the links in the text file I would like to display the first ten links within that file on to a webpage. If my intentions are unclear its similar to the Headlines script (it displays the last 5 news topics). So basically I would put a PHP script on my page that would call a file to display these links!. I have no clue where to begin any tutorials/help would be much appreciated!

Thanks for your time!
- Matt

Share this post


Link to post
Share on other sites
I suggest using a database but
[code=php:0]
<?
$farray = file("links.txt");
$c = count($farray);
if($c > 5) { $s = $c - 5; } else { $s = 0; }
//foreach($farray as $key => $value) {
//echo $value;
//}
$i = 0;
while($i <= 5) {
echo $farray[$s];
$i++;
$s++;
}
?>
[/code]
will display the last 5 lines in links.txt

If you use this youll have to put the links in the form of
[code]<a href="http://site.com/page.ext">Text to display</a>[/code]

Share this post


Link to post
Share on other sites
Awesome thank you very much for pointing me in the right direction! Ill let you know how it goes! Appreciate it !! =)

-Matt

Share this post


Link to post
Share on other sites
http://www.w3schools.com/php/php_file.asp is a short tutorial that might help you...

Share this post


Link to post
Share on other sites
Can anyone help me? when i insert this code , everything in red is displayed as regular text on my page.. Why ?

<?php
$farray = file("links.txt");
$c = count($farray);
if($c > [color=red]5) { $s = $c - 5; } else { $s = 0; }
//foreach($farray as $key => $value) {
//echo $value;
//}
$i = 0;
while($i <= 5) {
echo $farray[$s];
$i++;
$s++;
}
?>[/color]

Share this post


Link to post
Share on other sites

×

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.