I want to enter information in the order of user ID in Excel

Viewed 23

I want to enter information in the order of user ID in Excel. For example, if a user ID has 3 orders, I need to enter her 3 orders first and then the next customers in the same order. just like db: enter image description here But the code output: enter image description here The correct output is line 11 onwards

$users = "837|3710|4543";
$connect->set_charset("utf8");

      require('Classes/PHPExcel.php');
$phpExcel = new PHPExcel;
$inputFileType = PHPExcel_IOFactory::identify("hadi111.xlsx");
$phpExcel = PHPExcel_IOFactory::createReader("$inputFileType");
$phpExcel = $phpExcel->load('hadi111.xlsx'); 
$writer = PHPExcel_IOFactory::createWriter($phpExcel, "Excel2007");
$sheet = $phpExcel ->getActiveSheet();
$start = 2;
$ex = explode("|",$users);
foreach($ex as $usercode){
    if(!is_file("chek/$usercode")){
        if(!is_file("chek/$usercode")){
    $get = mysqli_query($connect, "select * from exel where id = '$usercode'");
while($row = $get->fetch_assoc()){
  $res[] = $row;
}
echo json_encode($res);
foreach($res as $record){
    $sheet ->getCell("C$start")->setValue($record['melli']);
    $sheet ->getCell("E$start")->setValue($record['name']);
    $sheet ->getCell("Q$start")->setValue($record['price']);
    $sheet ->getCell("P$start")->setValue($record['count']);
    $sheet ->getCell("O$start")->setValue($record['code']);
    $sheet ->getCell("J$start")->setValue($record['status']);
    $sheet ->getCell("G$start")->setValue($record['postal']);
     $sheet ->getCell("A$start")->setValue($record['date']);
     $sheet->getColumnDimension('A')->setAutoSize(true);
     $sheet->getColumnDimension('C')->setAutoSize(true);
     $sheet->getColumnDimension('E')->setAutoSize(true);
     $sheet->getColumnDimension('Q')->setAutoSize(true);
     $sheet->getColumnDimension('P')->setAutoSize(true);
     $sheet->getColumnDimension('O')->setAutoSize(true);
     $sheet->getColumnDimension('J')->setAutoSize(true);
     $sheet->getColumnDimension('G')->setAutoSize(true);
    $start++;
}
touch("chek/$usercode");
}
}else{
$start++;
}
}
$writer->save('hadi2w.xlsx'); 
0 Answers
Related