0

php と fpdf に問題があります。

fpdf と php を使用してレポートを pdf 形式で作成し、教師が教えていることを生徒に示したいと考えています。

私が欲しいのは、fpdfが同じフィールドを持つ複数の列を持つページを作成する必要があるということです。

写真のリンク: http://i1267.photobucket.com/albums/jj552/ThePerfectH/abc.png

ご覧のとおり、この画像では、1 つの列に 30 までのデータが必要で、その後は 1 つのページの別の列に移動する必要があります。

コード例:

$result=mysql_query("select p.p_sname as pap from sgm, students st
    left join sps on st.studentid=sps.studentid
    left join papers p on p.p_id=sps.paperid where p.type='optional' and
    sgm.studentid=st.studentid and sgm.groupid=3 and st.course=3 and
    st.status='Regular' order by name");
    if($result === FALSE)
{
die(mysql_error()); // better error handling
}
$i=0;
$max=30;
$s=1;
$row_height = 6;
$y_axis = 33 + $row_height;
while($row = mysql_fetch_array($result))
{
//If the current row is the last one, create new page and print column title
if ($i == $max)
{
    $y_axis= 33 + $row_height;
    $pdf->SetX(80);
    $pdf->SetTextColor(153,0,102);
    $pdf->SetFont('Arial','',10);
        //print column titles for the current page
    $pdf->SetY(33);
    $pdf->SetX(80);
    $pdf->Cell(20,6,'S No.',1,0,'C',1);
    $pdf->SetY($y_axis);
    $pdf->SetX(80);
    $pdf->Cell(20,6,$s,1,0,'C',1);
    $y_axis = $y_axis + $row_height;
        $i = $i + 1;
    $s=$s+1;


}

        $rollno=$row['rollno'];
    $name=$row['name'];
    $cat=$row['cat'];
    $pap=$row['pap'];
    $pdf->SetY($y_axis);
    $pdf->SetX(48);
    $pdf->SetFont('Arial','',10);
    $pdf->Cell(20,6,$s,1,0,'C',1);
    //Go to next row
    $s=$s+1;
    $y_axis = $y_axis + $row_height;

        $i = $i + 1;    }       

写真でわかるように、これは、新しい列を 1 つだけ作成した後、行の重複につながります。

誰でも助けることができますか。

4

1 に答える 1

0

SetX を x_axis に変更することでそれを行い、30 に達すると x_axis に追加します

于 2012-07-22T20:46:48.020 に答える