tags:

views:

779

answers:

1

Is there any php/mysql software that can pull data from a mysql database or a csv file, and allow you to edit, perhaps copy/paste new rows, then save this file as a csv?

needs to be web based. any pointers will help.

+2  A: 

Are the fgetcsv (http://us3.php.net/manual/en/function.fgetcsv.php) and fputcsv (http://us3.php.net/manual/en/function.fputcsv.php) functions sufficient?

In terms of fetching data from a mysql database:

$result = mysql_query($some_query);

$file = fopen('some_file', 'w');

$is_first = true;

while($row = mysql_fetch_assoc($result)) {

   if($is_first) {

       fputcsv($file, array_keys($row));
       $is_first = false;
   }

   fputcsv($file, $row);

}

fclose($file);

Haven't tested it, but that will probably work to convert a mysql query result into a csv file, including the column names at the top of the file.

Kazar
i was hoping there was something pre-made that i could learn from. Not really skilled enough to build this from scratch.
Patrick
Kazar really pointed you in the right direction. The description you mentioned doesnt sound like something that would be available in a 'generic' form. Most cases where that sort of functionality is needed would be buried within a larger system.
Ben Reisner