Return to Snippet

Revision: 32124
at September 18, 2010 22:51 by paschim


Initial Code
$file = fopen("myfile.csv", "r");
$sql = "INSERT INTO table(field1, field2, field3...";
while(!feof($file))
  {
      $fields = explode(',', fgets($file));
      $sql .= "VALUES("
      foreach($fields as $field)
      {
         $sql .= "$field, ";
      }
      $sql = substr($sql, 0, -2);
      $sql .= "), ";
  }
  $sql = substr($sql, 0, -2);
 fclose($file);
  mysql_query($sql);

Initial URL

                                

Initial Description

                                

Initial Title
importing excel to mysql db

Initial Tags
excel

Initial Language
PHP