Modify Text Files

Discussion in 'PHP' started by hiyatran, Oct 4, 2012.

  1. #1
    I figure out how to write all the entries from my database onto a text file.


    header("Content-Type: text/plain"); 
    header("Content-Disposition: 
    Attachment; filename=test.txt"); 
    header("Pragma: no-cache"); 
    exit;              
    
    Code (markup):
    How do I modify the text file??
    Each entries (or row) have 5 elements in it and there are multiple entries in my database.
    How do I write each elements follow by a comma onto a text file? Each row in the database would have a new line in my text file as well.

    tks
     
    hiyatran, Oct 4, 2012 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    Why would you do this? In most cases file based storage like this is an extremely inefficient way to store information. If you have to do it, I would use XML or something similar to maintain data integrity.
     
    jestep, Oct 4, 2012 IP
  3. Vick.Kumar

    Vick.Kumar Active Member

    Messages:
    138
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    90
    #3
    You could write a php script, where it auto-loads the text file into html form page view, and then modify and update using php. But I'd recommend keeping everything database related, may I ask why you're trying inefficient ways?
     
    Vick.Kumar, Oct 5, 2012 IP