import data from excel to mysql using php code – How to Import Excel/CSV file to MySQL Database using PHP?

import data from excel to mysql using php code – import excel file into mysql database tutorial first of all Install PHPExcel with Composer.

import data from excel to mysql using php code

learn import excel file into mysql table with complete source code and explanation. also you can learn to Upload a CSV(excel) file and import into database using PHP and MYSQL.

1.Download Package

So first let’s download from here :

https://github.com/nuovo/spreadsheet-reader

Click Here to download PHP Excel

2.Create connect_db.php file


3.Create index.php file

Therefor let’s copy bellow source code as well as put it into index.php file.
index.php




	Excel Uploading PHP - www.pakainfo.com
	




Excel Upload - File

Download Demo File from here : example.ods

Don’t Miss : import excel file into mysql database tutorial

4.Create Upload Folder

So, let’s create fileStoreNew.php file and put bellow code:
fileStoreNew.php

sheets());

    echo "You have total ".$countAllData." sheets".

    $table_view="";
    $table_view.="";

    /* For Loop for all sheets */
    for($i=0;$i<$countAllData;$i++){

      $Reader->ChangeSheet($i);

      foreach ($Reader as $dataResult)
      {
        $table_view.="";
        $title = isset($dataResult[0]) ? $dataResult[0] : '';
        $livecomments = isset($dataResult[1]) ? $dataResult[1] : '';
        $table_view.="";
        $table_view.="";
        $table_view.="";
        $query = "insert into items(title,livecomments) values('".$title."','".$livecomments."')";

        $mysqli->query($query);
       }
    }

    $table_view.="
Titlelivecomments
".$title."".$livecomments."
"; echo $table_view; echo "
Data Inserted in MySQL dababase"; }else { die("
Sorry, File type is not allowed. Only Excel file."); } } ?>

I hope you get an idea about import data from excel to mysql using php code.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment