SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2010
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Modify Text files

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

    Code:
    header("Content-Type: text/plain");
    header("Content-Disposition: Attachment; filename=test.txt");
    header("Pragma: no-cache");
    exit;
    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

  2. #2
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,162
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Start with fetching the results from the database first (using a while, or foreach, or for loop), once you have that, you will use fopen (before your loop), and fwrite (inside your loop), then fclose (after your loop).

    If you need a more thorough example, let me know.

  3. #3
    SitePoint Enthusiast
    Join Date
    Jun 2010
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm thinking putting all my sql onto an array then read each element with a for/while loop
    But how do I break up each element in the entries, so I can read it??


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
  •