php - PHPExcel - Getting irrelevant value in MySQL -


whenever import excel file mysql using phpexcel don't values , values inserted irrespective columns.

but when use echo showing excel file shows exact report.

also, want few selected columns imported 10-15 columns.

thanks in advance

my code

<?php     //include following 2 files     require 'c:\xampp\phpexcel_1.7.9_doc\classes\phpexcel.php';     require_once 'c:\xampp\phpexcel_1.7.9_doc\classes\phpexcel\iofactory.php';      $conn = mysql_connect("localhost","root",""); mysql_select_db("invoice",$conn);  $file=$_post['file']; $srow=$_post['srow'];    $objphpexcel = phpexcel_iofactory::load($file); foreach ($objphpexcel->getworksheetiterator() $worksheet) {     $worksheettitle     = $worksheet->gettitle();     $highestrow         = $worksheet->gethighestrow(); // e.g. 10     $highestcolumn      = $worksheet->gethighestcolumn(); // e.g 'f'     $highestcolumnindex = phpexcel_cell::columnindexfromstring($highestcolumn);     $nrcolumns = ord($highestcolumn) - 64;     echo "<br>the worksheet ".$worksheettitle." has ";     echo $nrcolumns . ' columns (a-' . $highestcolumn . ') ';     echo ' , ' . $highestrow . ' row.'; }    echo 'data: <table width="100%" cellpadding="3" cellspacing="0"><tr>'; ($row = $srow; $row <= $highestrow-1; ++ $row) {    echo '<tr>';    ($col = 0; $col < $highestcolumnindex; ++ $col) {        $cell = $worksheet->getcellbycolumnandrow($col, $row);        $val = $cell->getvalue();        if($row === 1)             echo '<td style="background:#000; color:#fff;">' . $val . '</td>';        else            echo '<td>' . $val . '</td>';    } echo '</tr>'; } echo '</table>';     ($row = $srow; $row <= $highestrow; ++ $row) {     $val=array(); ($col = 0; $col <= $highestcolumnindex; ++ $col) {    $cell = $worksheet->getcellbycolumnandrow($col, $srow); $val[] = $cell->getvalue();  } $dropdownval=$_post['menu'];  if ($dropdownval!='none') { $sql="insert $dropdownval(`bkng date`,`id number`,`pax name`,`ticket number`,`pnr`,`sector`,`travel date`,`basic`,`tax`,`net payable`) values('".$val[1]."','".$val[2]."','".$val[3]."','" .$val[4]."','".$val[5]."','".$val[6]."','".$val[7]."','".$val[8]."','".$val[9]."','".$val[10]."')"; mysql_query($sql)or die('invalid query: ' . mysql_error());      if(mysql_query($sql))     echo "successfully uploaded ".$file;     else         echo "error while uploading ".$file;     //echo $sql."\n"; }  else     {     $tname=$_post['tname']; $createtable="create table $tname(  `bkng date` date not null ,  `id number` int not null ,  `pax name` varchar( 100 ) not null ,  `ticket number` varchar( 100 ) not null ,  `pnr` varchar( 50 ) not null ,  `sector` varchar( 50 ) not null ,  `travel date` date not null ,  `basic` decimal not null ,  `tax` decimal not null ,  `net payable` decimal not null)"; mysql_query($createtable);  $sql1="insert $tname(`bkng date`,`id number`,`pax name`,`ticket number`,`pnr`,`sector`,`travel date`,`basic`,`tax`,`net payable`) values('".$val[1]."','".$val[2]."','".$val[3]."','" .$val[4]."','".$val[5]."','".$val[6]."','".$val[7]."','".$val[8]."','".$val[9]."','".$val[10]."')";     mysql_query($sql1)or die('invalid query: ' . mysql_error());         if(mysql_query($sql1))     echo "table $tname has been created...successfully uploaded ".$file;     else         echo "error while uploading ".$file; }  }  ?> 


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -