In the 2nd image blank rows are also displaying while uploading the csv file in php how to display only non empty cells in html in php.
CodePudding user response:
Well I can guide you little that.
$Cols=trim(implode(",",$sheet[1]));
$ColArr=explode(",",$Cols);
By doing this code you will get columns in $ColArr apply function of empty() to check weather it is null or not.
CodePudding user response:
My code . Here empty row is adding to database how to avoid that
$file = $_FILES['upldloa']['tmp_name'];
$handle = fopen($file,"r");
$enqry_status = '0';`
$status = 1;
$i=1;
while ($data = fgetcsv($handle)) {
//print_r($data);exit();
if($i>1)
{
if($data[0] != ''){
$bulktdr = $data[0];
}
else if($data[0] == ''){
$bulktdr='';
}
if (isset($bulktdr)) {
mysqli_query($con ,"INSERT INTO `tend_sview_bulk_apv`( `bulk_id`, `tdr`, `tender_authour`, `tend_brief`,`b_documentfees`,`b_emd`, `tend_bamount`, `bulk_location`, `b_state`, `b_due_date`,`b_tenderno`, `created_by`, `enqry_status`, `created_on`, `status`) VALUES
(
'".$last_id."',
'".$bulktdr."',
'".addslashes($data[1])."',
'".addslashes($data[2])."',
'".addslashes($data[3])."',
'".addslashes($data[4])."',
'".addslashes($data[5])."',
'".addslashes($data[6])."',
'".addslashes($data[7])."',
'".addslashes($data[8])."',
'".addslashes($data[9])."',
'".$created_by."',
'".$enqry_status."',
'".$created_on."',
'".$status."'
)
");
}
}
$i ;
}
`