Skip to main content

Posts

Showing posts from June 21, 2014

Insert Data from excel into database

<?php //your database connection here... //$_POST["Import"]   this is data which you want to insert $sql=''; if(isset($_POST["Import"])) { $filename=$_FILES["file_product"]["tmp_name"]; $type=$_FILES["file_product"]["type"]; //print_r($_FILES);  if($_FILES["file_product"]["size"] > 0) {   $file = fopen($filename, "r"); while (($emapData = fgetcsv($file, 50000, ",")) !== FALSE) {  if($emapData[0]!="")  {   $t=mysql_escape_string(trim($emapData[2]));   $t1=strlen($t);   $city=mysql_escape_string(trim($emapData[7]));   $city1=strlen($city);   $state=mysql_escape_string(trim($emapData[8]));   $state1=strlen($state);   $zip=mysql_escape_string(trim($emapData[9]));   $zip1=strlen($zip);   $sql=rtrim($sql,','); $sql ="insert into yourtable (phone_no, firstname, lastnam