Old 29-02-2004, 06:47   #1 (permalink)
dcd
Senior Member
 
dcd's Avatar
 
Join Date: Feb 2003
Location: Canterbury
Posts: 115
Use text from a .txt file

Hi.

A client has a news section that he keeps up to date in a text file. I have designed the html section of his site and he wants the news layer to display the text in the .txt file he has. This is so he only has to update on text file instead of 30-40 different html pages!

Is there some simple javascript or something that I can use?
  Reply With Quote
Old 29-02-2004, 07:30   #2 (permalink)
gray
i still want paying
 
gray's Avatar
 
Join Date: Oct 2003
Location: newcastle, uk
Posts: 4,728
I would use php

Code:
<?php $read = fopen("news.txt", "r"); $data = fread($read, filesize($read)); echo $data; ... ?>

should work if you put that where you want the news to be (obviously the file would have to be a php file not html (just change extension)
  Reply With Quote
Old 29-02-2004, 07:36   #3 (permalink)
dcd
Senior Member
 
dcd's Avatar
 
Join Date: Feb 2003
Location: Canterbury
Posts: 115
never done any php, if I just save that the current html page as a php page with that code inserted will it work?
  Reply With Quote
Old 29-02-2004, 07:40   #4 (permalink)
gray
i still want paying
 
gray's Avatar
 
Join Date: Oct 2003
Location: newcastle, uk
Posts: 4,728
should do, if the server has php installed (it wont work locally, so test online.. unless you install a webserver, php etc but thats another story)

you could always use flash
  Reply With Quote
Old 29-02-2004, 07:41   #5 (permalink)
dcd
Senior Member
 
dcd's Avatar
 
Join Date: Feb 2003
Location: Canterbury
Posts: 115
he doesn't want flash so will give that a try! Thanks
__________________
Living in the Slow Lane
  Reply With Quote
Old 29-02-2004, 09:10   #6 (permalink)
Bill Posters
trouble free and loverlee
 
Join Date: Mar 2003
Location: YooKay
Posts: 2,929
Alt:

Code:
<? include("news.txt"); ?>

Effectively the same, aren't they? (…he asked in his precocious newbie/chancer tone of voice)
  Reply With Quote
Old 29-02-2004, 09:24   #7 (permalink)
smallbeer
I Ain't Losing Any Sleep™
 
Join Date: Apr 2003
Posts: 5,240
Yep your way is just as effective Bill but Gray's would offer the option (if needed) of writing, reading and deleting data from the text file. Useful when the job doesn't quite require the effort of setting up a db but maybe more user friendly than simply FTP.
__________________
That's fuckin' ingenious, if I understand it correctly. It's a Swiss fuckin' watch.
  Reply With Quote
Old 29-02-2004, 09:29   #8 (permalink)
pixelpyro
Senior Member
 
Join Date: May 2003
Posts: 658
Smallbeer - not familiar with php so sorry if it's a dopey question but, how would Gray's solution offer writing, reading and deleting data from the text file?
__________________
feel the heat.
  Reply With Quote
Old 29-02-2004, 09:48   #9 (permalink)
smallbeer
I Ain't Losing Any Sleep™
 
Join Date: Apr 2003
Posts: 5,240
Quote:
Originally Posted by pixelpyro
Smallbeer - not familiar with php so sorry if it's a dopey question but, how would Gray's solution offer writing, reading and deleting data from the text file?
On it's own it doesn't but php does have the functionality to do more...

http://www.google.co.uk/search?hl=en...file+php&meta=

Should explain quicker than I can.
__________________
That's fuckin' ingenious, if I understand it correctly. It's a Swiss fuckin' watch.
  Reply With Quote
Old 29-02-2004, 09:59   #10 (permalink)
pixelpyro
Senior Member
 
Join Date: May 2003
Posts: 658
Nice one - really need to look further into PHP - Any recommednations of good books.
__________________
feel the heat.
  Reply With Quote
Old 29-02-2004, 10:05   #11 (permalink)
smallbeer
I Ain't Losing Any Sleep™
 
Join Date: Apr 2003
Posts: 5,240
Quote:
Originally Posted by pixelpyro
Nice one - really need to look further into PHP - Any recommednations of good books.
I like this one - http://www.amazon.co.uk/exec/obidos/...545574-0569208
__________________
That's fuckin' ingenious, if I understand it correctly. It's a Swiss fuckin' watch.
  Reply With Quote
Old 29-02-2004, 10:17   #12 (permalink)
pixelpyro
Senior Member
 
Join Date: May 2003
Posts: 658
I thank you
__________________
feel the heat.
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8