Results 1 to 4 of 4

Thread: dump results to text/excel file

  1. #1

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945

    dump results to text/excel file

    Is it possible to take the results of a query and write them out to either a comma delimited file or to an excel file?
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  2. #2

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    Got it except for writing to an actual excel file:
    PHP Code:
    $filename 'test.csv';
    $somecontent "Add this to the file\n";

    // Let's make sure the file exists and is writable first.
    //if (is_writable($filename)) {

       // In our example we're opening $filename in append mode.
       // The file pointer is at the bottom of the file hence 
       // that's where $somecontent will go when we fwrite() it.
       
    if (!$handle fopen($filename'a')) {
             echo 
    "Cannot open file ($filename)";
             exit;
       }

       
    // Write $somecontent to our opened file.
       
    if (fwrite($handle$somecontent) === FALSE) {
           echo 
    "Cannot write to file ($filename)";
           exit;
       }
       echo 
    "Success, wrote ($somecontent) to file ($filename)";
       
       
    fclose($handle);
                       
    /*} else {
       echo "The file $filename is not writable";

    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  3. #3

    Thread Starter
    Frenzied Member ober0330's Avatar
    Join Date
    Dec 2001
    Location
    OH, USA
    Posts
    1,945
    And I have no idea why it's doubling up my code.
    format your code!! - [vbcode] [/vbcode]

    ANSWERS CAN BE FOUND HERE!!

    my personal company

  4. #4
    <?="Moderator"?> john tindell's Avatar
    Join Date
    Jan 2002
    Location
    Brighton, UK
    Posts
    1,099
    If you still want to dump the results into an Excel file then look at COM()

    http://uk.php.net/manual/en/ref.com.php

    There is also some comments about using excel with mysql I think.

    Hope it helps

Posting Permissions

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



Click Here to Expand Forum to Full Width