Jump to content


Photo

Simple file Display Script


  • Please log in to reply
4 replies to this topic

#1 moOt

moOt
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 08 August 2006 - 09:54 PM

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

#2 corbin

corbin
  • Staff Alumni
  • Advanced Member
  • 8,129 posts

Posted 08 August 2006 - 10:09 PM

I suggest using a database but
<?
$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++;
}
?>
will display the last 5 lines in links.txt

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

Why doesn't anyone ever say hi, hey, or whad up world?

#3 moOt

moOt
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 08 August 2006 - 10:13 PM

Awesome thank you very much for pointing me in the right direction! Ill let you know how it goes! Appreciate it !! =)

-Matt

#4 corbin

corbin
  • Staff Alumni
  • Advanced Member
  • 8,129 posts

Posted 08 August 2006 - 10:17 PM

http://www.w3schools...hp/php_file.asp is a short tutorial that might help you...
Why doesn't anyone ever say hi, hey, or whad up world?

#5 moOt

moOt
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 11 August 2006 - 04:48 PM

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 > 5) { $s = $c - 5; } else { $s = 0; }
//foreach($farray as $key => $value) {
//echo $value;
//}
$i = 0;
while($i <= 5) {
echo $farray[$s];
$i++;
$s++;
}
?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users