Transpher mysql table data to csv format using php

Discussion in 'PHP' started by nitu, May 3, 2008.

  1. #1
    I want to Transpher mysql table data to csv format using php.
    Can anyone have good script for it?
     
    nitu, May 3, 2008 IP
  2. Bagi Zoltán

    Bagi Zoltán Well-Known Member

    Messages:
    364
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    110
    #2
    If the tables are available at a database server you may use the export function of the phpmyadmin in order to save the database to csv fromat.
     
    Bagi Zoltán, May 3, 2008 IP
  3. PowerExtreme

    PowerExtreme Banned

    Messages:
    2,118
    Likes Received:
    75
    Best Answers:
    0
    Trophy Points:
    0
    #3
    yea phpmyadmin does this use it and its available on most of the servers
     
    PowerExtreme, May 3, 2008 IP
  4. vishnups

    vishnups Banned

    Messages:
    166
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Hi,

    He is interested in doing it through php. I have attached a class file which you can use for this purpose. It is an easy to use PHP class to read and write CSV data properly.You can modify it to suit your purpose. And here are some examples on how to implement the class
    
    Sample codes illustrating how to use the parseCSV class.
    
    [B][U]General:[/U][/B]
    
    $csv = new parseCSV('data.csv');
    print_r($csv->data);
    
    [B][U]Tab delimited, and encoding conversion:[/U][/B]
    
    $csv = new parseCSV();
    $csv->encoding('UTF-16', 'UTF-8');
    $csv->delimiter = "\t";
    $csv->parse('data.tsv');
    print_r($csv->data);
    
    [U][B]Auto-detect delimiter character:[/B][/U]
    
    $csv = new parseCSV();
    $csv->auto('data.csv');
    print_r($csv->data);
    
    [U][B]Modify data in a CSV file:[/B][/U]
    
    $csv = new parseCSV();
    $csv->sort_by = 'id';
    $csv->parse('data.csv');
    # "4" is the value of the "id" column of the CSV row
    $csv->data[4] = array('firstname' => 'John', 'lastname' => 'Doe', 'email' => 'john@doe.com');
    $csv->save();
    
    [U][B]Add row/entry to end of CSV file:[/B][/U]
    
    Only recommended when you know the exact structure of the file.
    
    $csv = new parseCSV();
    $csv->save('data.csv', array('1986', 'Home', 'Nowhere', ''), true);
    
    [U][B]Convert 2D array to csv data and send headers to browser to treat output as a file and download it:
    [/B][/U]
    $csv = new parseCSV();
    $csv->output (true, 'movies.csv', $array);
    
    
    Code (markup):
     

    Attached Files:

    vishnups, May 3, 2008 IP