在PHP中将特定行详细信息从数据库显示到PDF页面

I have an issue, I have retrieved all the details of a row into pdf page but the issue is, when i click it echo's the id in the browser but not the specific id record from database.

On a little change, shows first row from mysql on every id button clicked.

Sometime displays all the record on the PDF page.

Example: If one record covers 2 pages of PDF page then it shows like 10 pages of all the rows showing in pdf page.

When I change the sql query like Select * from students where id = '$id' then this gives this error.

(Undefined variable: id in C:\xampp\htdocs\login Registration system\admin\includes\pdf\index.php on line 13)

Please help me out .

Its the Button from Where i call the pdf page:

<th scope="row"><a href="includes/pdf/index.php?action=select&id=<?php echo $id; ?>"  class="btn btn-success">Print</a></th>

Now its the PDF index page :

<?php
require('library/fpdf.php');
include("pconnect.php");

$sql = "SELECT * FROM students ";
$result = mysqli_query($con, $sql);

while($rows = mysqli_fetch_array($result))
{
  $pdf = new FPDF();
  $pdf->AddPage();
  $pdf->SetFont('Arial', 'B', 10);
  $pdf->Ln();
  $pdf->Ln();

  $pdf->Ln();

  $pdf->SetFont('times', 'B', 10);
  $pdf->Cell(30, 20, 'Name on Passport', 1, 0);
  $pdf->Cell(60, 10, $rows['firstname'], 1, 0, 'C');

  $pdf->SetX(40);
  $pdf->Cell(60, 10, $rows['lastname'], 1, 0, 'C');

  $pdf->Cell(30, 10, 'Nationality', 1, 0, 'C');
  $pdf->Cell(45, 10, $rows['nationality'], 1, 0, 'C');

  $pdf->SetX(85);
  $pdf->Cell(28, 10, 'Place of Birth', 1, 0);
  $pdf->Cell(42, 10, $rows['placeofbirth'], 1, 1, 'C');

  $pdf->Cell(30, 10, 'Date of Birth', 1, 0);
  $pdf->Cell(73, 10, $rows['dateofbirth'], 1, 0, 'C');
  $pdf->Cell(42, 10, $rows['gender'], 1, 0, 'C');

  $pdf->SetY(60);
  $pdf->SetX(155);
  $pdf->Cell(45, 40, $rows['Photo'], 1, 1, 'C');

  $pdf->Output();
}?>

Thankyou so much for your comments, I have solved it out by myself. The Issue was i was calling the action but in the index page there was no action.

if(($_GET['action'] == 'select') && isset($_GET['id'])) {

$id = $_GET['id'];
$sql = "Select * FROM students WHERE id = '$id'";
$query = mysqli_query($con, $sql);

$pdf=new FPDF();
$pdf->AddPage();
while($rows=mysqli_fetch_array($query))
   {

        $pdf->SetFont('Arial','B',10);
        $pdf->Ln();
        $pdf->Ln();
   }
   $pdf->Output();
  }