Need someone to convert mySQL data to Excel $5

Discussion in 'PHP' started by richardandrews2007, Dec 17, 2007.

  1. #1
    Hi ,

    I have a MySql file which i need to be converted to Excel, Access or simple notepad file.

    Please let me know if anyone can help.

    Can pay $5 for this easy thing. You just need to import the sql when the code will run, u will have a table. Export that table to excel or any other format and send that to me.

    Thanks
     
    richardandrews2007, Dec 17, 2007 IP
  2. kishore415

    kishore415 Well-Known Member

    Messages:
    1,462
    Likes Received:
    41
    Best Answers:
    0
    Trophy Points:
    160
    #2
    am intrested ....send me the files
     
    kishore415, Dec 17, 2007 IP
  3. sunnyverma1984

    sunnyverma1984 Well-Known Member

    Messages:
    342
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    120
    #3
    no need to pay any $ you can do it your self use phpmyadmin it has option to export data in excel csv format
    if you don't no how to use phpmyadmin then give me your database file i will convert it for free.
     
    sunnyverma1984, Dec 17, 2007 IP
  4. alhen

    alhen Peon

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You can stick this code in a page all by itself, name it something like "export.php", then just change your mysql info. You need to change:

    localhost (although, localhost can most likely stay the same) username, password, database and usertable.

    After you have that file in place, just go to it in your browser... it should give you the option to open or save in Excel.

    <?php 
    header("Content-type: application/octet-stream"); 
    header("Content-Disposition: attachment; filename=NAME_YOUR_FILE.xls"); 
    header("Pragma: no-cache"); 
    header("Expires: 0");  
    mysql_connect(localhost,username,password); 
    @mysql_select_db(database) or die("Unable to select database"); 
    $select = "SELECT * FROM usertable; 
    $export = mysql_query($select); 
    $count = mysql_num_fields($export); 
    for ($i = 0; $i < $count; $i++) { 
    $header .= mysql_field_name($export, $i)."\t"; 
    } 
    while($row = mysql_fetch_row($export)) { 
    $line = ''; 
    foreach($row as $value) { 
    if ((!isset($value)) OR ($value == "")) { 
    $value = "\t"; 
    } else { 
    $value = str_replace('"', '""', $value); 
    $value = '"' . $value . '"' . "\t"; 
    } 
    $line .= $value; 
    } 
    $data .= trim($line)."\n"; 
    } 
    $data = str_replace("\r", "", $data); 
    if ($data == "") { 
    $data = "\n(0) Records Found!\n"; 
    } 
    print "$header\n$data"; 
    ?> 
    PHP:
     
    alhen, Dec 17, 2007 IP
  5. richardandrews2007

    richardandrews2007 Active Member

    Messages:
    794
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    53
    #5
    Many Thanks, its done
     
    richardandrews2007, Dec 20, 2007 IP