Import csv file data into mysql database using php

Mysql Mysqli php Programming

Import csv file data into mysql database using php

In this Post We Will Explain About is Import csv file data into mysql database using php With Example and Demo.Welcome on – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to import csv file into mysql using php codeExample

In this post we will show you Best way to implement import csv file into mysql using php demo, hear for how to read csv file in php and store in mysqlwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.


here show eamples to core PHP with mysql we can easily read the simple CSV file data into database like as a mysql database. CSV (comma separator value) file contain the all data with simple separator comma. functions used to fgetcsv is used to read simple csv data.


$db_connect = mysql_connect("","root",""); 

if (isset($_FILES['livecsv']['size']) > 0) { 
    $file = $_FILES['livecsv']['tmp_name']; 
    $handle = fopen($file,"r"); 
    $name = $_FILES['livecsv']['name'];
    do { 
        if ($data[0]) { 
		$myquery = mysql_num_rows(mysql_query("SELECT user_id FROM user_mst WHERE user_id = '".addslashes(trim($data[1],'"'))."'"));
		if($myquery == 0 ) {
            mysql_query("INSERT INTO user_mst (user_name, user_id,user_file) VALUES 
    } while ($data = fgetcsv($handle,1000,",","'"));     // 

	echo '<script> window.loaction.href="../index.php?responseid=1" </script>';


<html xmlns=""> 
<title>Devloped By : Import a CSV File with PHP & MySQL</title> 
<?php if (isset($_GET['success'])) { echo "<b>Your simple file has been imported success.</b><br><br>"; } //generic simple success notice ?> 
<h1>Devloped By : - Import a CSV File with PHP AND MySQL Example</h1>
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1"> 
  select your file: <br /> 
  <input name="livecsv" type="file" id="livecsv" /> 
  <input type="submit" name="Submit" value="Submit" /> 

<p>We are Web Technology Experts and Team who provide you very Important information on Web Development information,Examples and Demo, Interview Questions and Answers, live project problem solution and their solution and online free tutorials – “”.



Your CSV simple data must be like below : CSV File Sample Data

919898225076, ravi
919974840402, live24udotcom
919898555554, itfiddledotcom
919985666854, MayurDhameliya


I hope you have Got What is import csv file into mysql database using phpmyadmin And how it works.I would Like to have FeadBack From My Blog( readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article( Are Most Always Welcome.

Related FAQ

Here are some more FAQ related to this Article:

  1.   Laravel redirect route with query string example
  2.   Laravel 5.7 Email Verification with Activation Tutorial Example
  3.   PHP - Paypal Payment Gateway Integration
  4.   Mouseover and Mouseout Effects using Jquery Example
  5.   PHP Class Inheritance call parent constructor
  6.   Laravel Global variable Sharing Data with all views
  7.   Laravel 6 Ajax CRUD Example
  8.   Export data mysql table to csv file using PHP
  9.   Laravel 6 Where null and Where not null eloquent query
  10.   react open new tab with url Example Tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *