Jump to content

Simple file Display Script


moOt

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
Link to comment
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]
Link to comment
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]
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.