The following PHP code gets all the images for a product from the database to display in a pdf document. How do we have it only get the first image, and ignore the rest, to add to the pdf document. TIA
// Adding Pages for Images
$sql="select * from es_pro_pic where prod_id=$id and type='images' and active='yes' and del='no'";
$result=mysql_query($sql);
if(mysql_num_rows($result)>0)
{
while($rs=mysql_fetch_array($result)) {
$logoFile = "picture/" . $rs['pic'];
$logoXPos = 10;
$logoYPos = 30;
$logoWidth = 190; // 2480
$logoHeight = ''; // 3508
$pdf->AddPage();
// Set PDF Cut Sheets
$pdf->SetTextColor($c_grey);
$pdf->SetFont('Arial', '', 14);
$pdf->Write(15, "Product Images: ");
$pdf->Ln(20);
$pdf->Image( $logoFile, $logoXPos, $logoYPos, $logoWidth );
}
}
Have you tried adding a LIMIT 1
to your sql query like that
$sql="select * from es_pro_pic where prod_id=$id and type='images' and active='yes' and del='no' LIMIT 1";
This would return only the first row.