Forum Moderators: coopster

Message Too Old, No Replies

loading of text files

         

manilaboy

6:38 am on Dec 4, 2004 (gmt 0)

10+ Year Member



hi please help me am new in php programming my problem is that i have combo box then upon chossing that it will be load by button then it will apear in textarea to edit after that it will save again to textfiles
please help me now

jatar_k

7:17 pm on Dec 4, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld manilaboy,

If I am understanding you correctly.

You want to load the contents of a txt file into e textarea, edit them and resave the txt file.

the steps involved are fairly straght forward

1. open the file using fopen [php.net], make sure you open it for reading and writing
2. get the contents of the file into a variable. You could use file_get_contents [php.net], fgets [php.net], fread [php.net] among others
3. echo [php.net] the contents of the variable into your textarea. something like
<textarea><? echo $myfilecontent;?></textarea>
4. once the changes are made you will need to fwrite [php.net] the content of your textarea back into the file

manilaboy

7:49 am on Dec 7, 2004 (gmt 0)

10+ Year Member



thanks but my problem is that the combo box have 7 or 8 value( 7 or 8 text files in the server) and upon clicking the button to show it in the text area pls help me to show the code i have no background yet in this php programing am a flash animator and dreamweaver designer

ergophobe

2:18 am on Dec 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



So let's say that your select box is named "choosefile" and each option is a file name.

On the sumbit page (the page specified in the "action" attribute of the form), your file name will be

$_POST['choosefile']

Follow up on the links jatar_k gave in his post and use that $_POST['choosefile'] (or whatever your select field is named) and follow the examples given for fopen() etc.