FPDF - PHP while循环只返回第一个值

I have this code:

  while ($row = mysql_fetch_array($result)) {
  $pdf=new PDF();
  $pdf->AliasNbPages();
  $pdf->AddPage();
  $pdf->SetFont('Times','',12);

  $pdf->SetFont('Arial','B',16);
  $pdf->Cell(42,10, "".$row["firstname"].$row["lastname"]);
  $pdf->Output();
  } 

It only generates the first value of the result (1 pdf page). There are supposed to be 9 results or pdf pages. In this case where the first and last name of all the players appear in 9 seperate pdf pages.

I tried the following PHP way but it did not work either.

while () {

 } echo "": 

Any ideas?

This should be what you are after

  $pdf = new PDF();
  $pdf->AliasNbPages();
  $pdf->SetFont('Arial','B',16);

  while ($row = mysql_fetch_array($result)) {
      $pdf->AddPage();
      $pdf->Cell(42, 10, $row["firstname"] . " " . $row["lastname"]);
  } 

  $pdf->Output();