Search
Left Quote    Treat your password like your toothbrush. Don't let anybody else use it, and get a new one every six months.
- Clifford Stoll    
Right Quote
 
[login] | [Register]
Forum Index » HTML and CSS » Viewing Topic and Replies
Post Reply


        Viewing Topic: Coding Webpage to Read .TXT File
  This user is offline  teachpower
  Subject: "Coding Webpage to Read .TXT File" Posted: @ 6:32 pm on Dec 30 2010   
Member #: 1228
Rank: User - (12)
Since: 04/05/10
Posts: 12
From: FL

Hello all. I hope you all are having a great Christmas holiday.

I am redoing a simple webpage for my father-in-law for our military collectables and antiques family business. He is not very computer literate and thought it would be easier for him to write/change descriptions for each of the collectables via a .TXT file. Then all he would have to do is upload the .txt file to the hosting server and the page would read it and display the text. I was figuring that this could be done through a CSS. Could someone tell me how to go about doing this so I can get him up and running.




-TeachPower TeachPower.net founder Education Resource Library for the classroom & boardroom
    Viewed: 6,418 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Coding Webpage to Read .TXT Fil..." Posted: @ 8:55 pm on Dec 31 2010    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

I think you can just include the text file in the HTML document. Like you said, whenever he uploads it (and if it's the exact same name), it will overwrite the previous and the new text will appear.


Code:

<? include($_SERVE R['DOCUMENT_RO OT'].'/path/t o/file/text.txt '); ?>






-bs0d | AllSyntax.com

    Viewed: 6,410 Times | Reply to This | To top
  This user is offline  teachpower
  Subject: "re: Coding Webpage to Read .TXT Fil..." Posted: @ 11:39 pm on Dec 31 2010    
Member #: 1228
Rank: User - (12)
Since: 04/05/10
Posts: 12
From: FL

Hiya bsod. Glad to see you still around these forums . The code you gave would have him changing and uploading 10 .TXT files per webpage? Is there a way to tell (through CSS file I am assuming) the text on these lines in the .TXT file to display here, and these next lines to display here, and so on? That way he only has one .TXT file per webpage?

Have A Happy New Year Everybody!!!




-TeachPower TeachPower.net founder Education Resource Library for the classroom & boardroom

    Viewed: 6,401 Times | Reply to This | To top
  This user is offline  bs0d
  Subject: "re: Coding Webpage to Read .TXT Fil..." Posted: @ 12:37 am on Jan 02 2011    

Member #: 1
Rank: Admin. - (1,505)
Since: 02/06/05
Posts: 600
From: USA

If PHP is installed on the webserver, you can have .php pages. The above code is PHP, so it must be executed within a webpage with a.php extension.

So wherever he wants the text to appear, use the above code. It's just saying to include the file in the page. where i have /path/to/file, you need to change that to the location of the text file in the web root. If it's in the primary directory, then you can delete "/path/to /file" and just put in the name of the file.

Example: File is named "updates. txt" in the "articles " folder. Then the code would be:
Code:

<? include($_SERVE R['DOCUMENT_RO OT'].'/articl es/updates.txt '); ?>

Each time he wants to put in updated text, just add to it and save. If he uploads a new file with the same exact name, it will overwrite the previous and all data in the original file is lost...

What you should consider doing for him is this:
  1. Se tup a table in a database for "updates "
  2. Create an HTML form that will store new records to the table (time stamped)
  3. Setup the page to retrieve the records from the table by date.
Then, he can type in his updates in the HTML form. This would be a lot easier for him vs. modifying text files and uploading them. It also allows for better management of the data. You can setup titles and other fields to categorize entries, tags, and so on - giving you more flexibility. It may take a little effort to setup at first, but once that's complete, it's setup forever!




-bs0d | AllSyntax.com

    Viewed: 6,381 Times | Reply to This | To top
Viewing Page: 1 of 1


1 |

You must be logged in to post on the forums. Login or Register








"AllSyntax.com" Copyright © 2002-2017; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank