0

这是我的剧本...

$students=isset ($_POST['students'])  ? $_POST['students'] : '';
for($i = 1; $i <= $students; $i++)
{
    $student = isset ($_POST['student'.$i]) ? $_POST['student'.$i]: '';

    $nilai= mysql_query ("SELECT * FROM student,s_semester where
    student.id=s_semester.student_id_fk AND student.id='$student' GROUP by student.id");

    $rowNya = 2;
    $no = 0;

    while ($data=mysql_fetch_array($nilai)) {
        $no = $no +1;


        $objPHPExcel->setActiveSheetIndex(0)
            ->setCellValue("A$rowNya", $no)
            ->setCellValue("B$rowNya", $student)
            ->setCellValue("C$rowNya", $data['idcard'])
            ->setCellValue("D$rowNya", $data['status']);
        $rowNya = $rowNya + 1;
    }

    // Rename sheet
    $objPHPExcel->getActiveSheet()->setTitle('Simple');
}

header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="database_anggota.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;

我的问题是,excel只输出一条出现的数据记录,我之前使用了复选框。我检查了3/4/5等,只出现了1条……如果输出pdf并且我使用FPDF,这个脚本运行良好。 .

请帮我...

4

1 回答 1

1

$rowNya = 2;移到循环之前for否则它将为每个学生 id 重置...否则您将在每个学生之后将其重置为 2,因此它将覆盖以前的学生详细信息

于 2013-03-01T09:37:18.353 回答