php - How can i get the value of each column in excel and insert to MySQL -


i newbie in sql , excel can guide me this?

this full script.

<?php  include 'function/functions.php';  $excel = $_post['files'];  $upload = $_post['upload'];  $query = mysql_query("insert clients (name, age, sex, address, contact_number) values ($excel)");  if(isset($upload))  {  $query;  }  ?>  <!doctype html>  <html>  <head>  </head>  <body>  <form action="" method="post" />  upload excel file<br />  <input type="file" name="files" /><br />  <input type="submit" value="upload" name="upload" />  </form>  </body>  </html>

i'll make simple code make easy understand me,(anyway sorry bad english)

my question is, how can insert each corresponding column in excel in mysql here's picture.

enter image description here

enter image description here

use fgetcsv contents excel file array values.hope works you.

 if($_files["file"]["size"] > 0)      {        $file = fopen($filename, "r");              while (($emapdata = fgetcsv($file, 10000, ",")) !== false)              {                 $sql = "insert import(name,age,sex,address,contact_number) values('$emapdata[0]','$emapdata[1]','$emapdata[2]','$emapdata[3]','$emapdata[4]')";                 mysql_query($sql);              }              fclose($file);              echo "csv file has been imported";      }      else      echo "invalid file:please upload csv file"; 

Comments

Popular posts from this blog

AbotX : How do you create a parallel crawler that stays on and can be added to at run time from new requests -

testing - Detect whether test has failed within fixture -

android - Create single AAR file from multiple modules using Gradle -