Results 1 to 5 of 5

Thread: write out from form as 1.txt, 2.txt, 3.txt

  1. #1
    Join Date
    May 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default write out from form as 1.txt, 2.txt, 3.txt

    have a working php form but I need the form to fopen ("w+") to a text file (1.txt)

    And the next time on form submission i need it to save as 2.txt, then 3.txt ...

    I suppose this is done with the count function, but don't know enough about php to beable to figure it out.

    Also how can I view these pages, (trying from a flash player) in the order of 1.txt, 2.txt, 3.txt?

    or even in php view as 1.txt and click a button then will be 2.txt, then 3.txt

    Any help with any part of this will be greatly appreciated. This has been an ongoing hair-pulling trying to help a friend type experiencing for over a year now, and the deadline is approaching soon.

    Thanks in advance,
    Joe

  2. #2
    Join Date
    Mar 2006
    Location
    Cleveland, Ohio
    Posts
    574
    Thanks
    6
    Thanked 5 Times in 5 Posts

    Default

    I suggest using a MySQL database. If you don't have the luxury of a database, you could write the number of the next text file in another text file. For example, say you have txtNum.txt, and it starts with the number 1 in it. PHP opens the file, reads the 1, makes 1.txt, then writes over the 1 with a 2 in txtNum.txt for next time. Then, next time, it will take the 2 out and go through the process again.

    If you have a database, though, you could eliminate the use of read/write text files altogether and just store values in an easier and more organized fashion.
    Thou com'st in such a questionable shape
    Hamlet, Act 1, Scene 4

  3. #3
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Similar solution here might need a little altering:
    http://www.dynamicdrive.com/forums/s...ad.php?t=53867

    If you have questions about it post them here.

    Actually that will need a bit of altering... I'll post something in a bit that will output the file as well.
    Corrections to my coding/thoughts welcome.

  4. #4
    Join Date
    May 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I can already get it to write the data from the form in the sequence of 1.txt 2.txt 3.txt but what i need is for a count function to work ( can't get the fucntion to work correctly yet) to count the files in the directory, then add them to the script to display 1.txt, 2.txt, 3.txt and so forth.

    That is what is driving me mad! Please give me an example in your response I am still learning php.

    Thanks for your responses!

  5. #5
    Join Date
    May 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ah think i may have come up with something:


    $add_script =add_script.txt
    $txt = txt_name.txt

    write from form to 1.txt, 2.txt, 3.txt at same time followed by $add_script append filename 1.txt to $txt

    so I would end up with the txt_name.txt looking something like

    some script followed by 1.txt
    some script followed by 2.txt

    think this may work, some work but maybe... will let you guys know.

    Thanks again.
    Last edited by jmituzas; 05-28-2010 at 03:19 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •