我正在尝试使用fpdf在php表单中单击生成多个(在群集中)pdf报告。
test_center是单独报告的集群。单击提交按钮时,它将调用fpdf的php文件。我的代码还没有工作。
到目前为止,在我的php中:
<?php
$program="select distinct test_center from sa_sase_result where school_year = '$content' ";
$prog=mysql_query($program);
while($row = mysql_fetch_array($prog))
{
echo '<option>' .$row['test_center'] . '</option>';
}
$message = null;
if($_SERVER["REQUEST_METHOD"] == "POST") {
if(!isset($_POST['depchair'])) {
} else if($_POST['depchair']=="") {
} else {
$input_depchair = addslashes($_POST['depchair']);
$input_depchair = addslashes($_POST['depchair']);
$pro_email="select control_no from sa_student_infoe y where y.test_center = '$input_depchair'";
$pro_address=mysql_query($pro_email);
$address = mysql_result($pro_address, 0);
}
}
?>
编辑:这是generate_pdf.php文件。
<?php
require('fpdf/fpdf.php');
mysql_connect("localhost", "root", "1234") or die(mysql_error());
mysql_select_db("final") or die(mysql_error());
$query = "SELECT * FROM sa_student_infoe, sa_student_edubg, sa_sase_result, sa_accounts";
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_array($result, MYSQL_BOTH)){
$control_no[] = $row['control_no'];
$surname[] = $row['surname'];
$fname[] = $row['fname'];
$mname[] = $row['mname'];
$app_no[] = $row['activation_code'];
$schoolyear[] = $row['schoolyear'];
$schl[] = $row['high_school'];
$schl_ad[] = $row['address_school'];
$apt[] = $row['aptitude'];
$mth[] = $row['math'];
$lng[] = $row['language'];
$sci[] = $row['science'];
$totgrd[] = $row['total_grade'];
$sx[] = $row['sex'];
}
$ctrl_no = array_shift( $control_no );
$sname = array_shift( $surname );
$firstname = array_shift( $fname );
$midname = array_shift( $mname );
$appno = array_shift( $app_no );
$schyear = array_shift( $schoolyear );
$school = array_shift( $schl );
$school_ad = array_shift( $schl_ad );
$aptitude = array_shift( $apt );
$math = array_shift( $mth );
$lang = array_shift( $lng );
$science = array_shift( $sci );
$gr = array_shift( $totgrd );
$sex = array_shift( $sx );
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','', 12);
$pdf->Cell(0, 0,'Mindanao State University', 0, 1, 'C');
$pdf->Cell(0, 10,'System Admission and Scholarship Examination (SASE)', 0, 1, 'C');
$pdf->Cell(0, 20,'REPORT OF RATING', 0, 1, 'C');
$pdf->Cell(30,5,'Control No:');
$pdf->Cell(100,5,$ctrl_no);
$pdf->Cell(30,5,'School Year:');
$pdf->Cell(-160,5,$schyear);
$pdf->Cell(30,15,'Activation Code:');
$pdf->Cell(10,15,' ' . $appno);
$pdf->Cell(50,40,$sname);
$pdf->Cell(50,40,$firstname);
$pdf->Cell(-120,40,$midname);
$pdf->Cell(15,50,'____________________________________________________________________');
$pdf->Cell(50,60,'LASTNAME');
$pdf->Cell(50,60,'FIRSTNAME');
$pdf->Cell(-50,60,'MIDDLENAME');
$pdf->Cell(-65,90,$school);
$pdf->Cell(67,100,'____________________________________________________________________');
$pdf->Cell(-15,110,'SCHOOL');
$pdf->Cell(-52,140,$school_ad);
$pdf->Cell(57,150,'____________________________________________________________________');
$pdf->Cell(-25,160,'SCHOOL ADDRESS');
$pdf->Cell(.1,190,'--------------------------------------------------------------------');
$pdf->Cell(-35,200,'--------------------------------------------------------------------');
$pdf->Cell(17,230,'AP(30):');
$pdf->Cell(18,230,$aptitude);
$pdf->Cell(17,230,'LU(80):');
$pdf->Cell(18,230,$lang);
$pdf->Cell(17,230,'MA(40):');
$pdf->Cell(18,230,$math);
$pdf->Cell(17,230,'SC(30):');
$pdf->Cell(18,230,$science);
$pdf->Cell(18,230,'GR(180):');
$pdf->Cell(-300,230,$gr);
$pdf->Cell(-10,260,'SEX:');
$pdf->Output("pdf_reports/SASE_report_rating/".$ctrl_no.".pdf", "F");
?>
答案 0 :(得分:0)
JS:
$("#id_of_generate_it_button").click(function () {
var N = 10;// ten pdf files will be generated and stored to the disk
for (i = 0; i < N; i++) {// 'the loop' -- walk thru all parallel generation processes connected to the event
parameter = N;// just to definite each single generated file
$.get("generate.php?q=parameter", function (data) {// start the ajax process to generate single document
// ?q=parameter i wrote just for passing to the php file some dependent parameter for each single file
// pdf #i generated
});
}// end for parallel generating N pdf files to the disk
});//end click
generate.php
中的:
$query = "SELECT * FROM sa_student_infoe, sa_student_edubg, sa_sase_result, sa_accounts WHERE some_field = ' . $_REQUEST['q'] . '";// single record from all