Bonjour,
Je souhaite à partir d'une base de données générer des étiquettes pour les imprimer sur du papier étiquette avec des dimensions bien particuliéres.
Connaissez vous un moyen d'arriver à cela ?
Merci d'avance
<?php echo $row_req_recupatordo['ordo_num']; ?>
Mais la j'ai essayé je vois po trop le truc ?$pdf->Cell(10,10,'<?php echo $row_req_recupatordo['ordo_num']; ?>',1);<?php
//Connect to your database
include("Connections/connec_pharma.php");
//Create new pdf file
$pdf=new FPDF();
//Open file
$pdf->Open();
//Disable automatic page break
$pdf->SetAutoPageBreak(true);
//Add first page
$pdf->AddPage();
//set initial y axis position per page
$y_axis_initial = 25;
//print column titles for the actual page
$pdf->SetFillColor(232,232,232);
$pdf->SetFont('Arial','B',12);
$pdf->SetY($y_axis_initial);
$pdf->SetX(25);
$pdf->Cell(30,6,'IDPAT',1,0,'L',1);
$pdf->Cell(100,6,'ORDONUM',1,0,'L',1);
$y_axis = $y_axis + $row_height;
//Select the Products you want to show in your PDF file
$result=mysql_query('SELECT idpat, ordo_num FROM ordonnance ORDER BY idpat',$link);
//initialize counter
$i = 0;
//Set maximum rows per page
$max = 25;
//Set Row Height
$row_height = 6;
while($row = mysql_fetch_array($result))
{
//If the current row is the last one, create new page and print column title
if ($i == $max)
{
$pdf->AddPage();
//print column titles for the current page
$pdf->SetY($y_axis_initial);
$pdf->SetX(25);
$pdf->Cell(30,6,'IDPAT',1,0,'L',1);
$pdf->Cell(100,6,'ORDONUM',1,0,'L',1);
//Go to next row
$y_axis = $y_axis + $row_height;
//Set $i variable to 0 (first row)
$i = 0;
}
$idpat = $row['idpat'];
$ordonum = $row['ordo_num'];
$pdf->SetY($y_axis);
$pdf->SetX(25);
$pdf->Cell(30,6,$idpat,1,0,'L',1);
$pdf->Cell(100,6,$ordo_num,1,0,'L',1);
//Go to next row
$y_axis = $y_axis + $row_height;
$i = $i + 1;
}
mysql_close($link);
//Create file
$pdf->Output();
?>
Le script n'est pas de moi j'ai juste essayé de l'adapter.$result=mysql_query('SELECT idpat, ordo_num FROM ordonnance ORDER BY idpat',$link);
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in c:\program files\easyphp1-7\www\pharmacie\test6.php on line 51while($row = mysql_fetch_array($result))
Warning: mysql_close(): supplied argument is not a valid MySQL-Link resource in c:\program files\easyphp1-7\www\pharmacie\test6.php on line 85mysql_close($link);
Et enfin :
$result=mysql_query("SELECT idpat,ordo_num FROM ordonnance GROUP BY ordo_num");
mysql_select_db('pharmacie') or die(mysql_error());
$resultfin = mysql_query($result);
Voila ca marche beaucoup mieux maintenant à part qu'il à tendance a me ressortir l'erreur array mais avec un petit rafraichissement, mon PDF s'ouvre. Bizard non ?<?php
define('FPDF_FONTPATH','font/');
require('fpdf.php');
//Connect to your database
include("connec_pharma.php");
//Create new pdf file
$pdf=new FPDF('P','mm','A4');
//Open file
$pdf->Open();
//Disable automatic page break
$pdf->SetAutoPageBreak(false);
//Add first page
$pdf->AddPage();
//set initial y axis position per page
$y_axis_initial = 8;
$y_axis = 8;
//Select the Products you want to show in your PDF file
//$result=mysql_query("SELECT idpat,ordo_num FROM ordonnance GROUP BY ordo_num");
$result=mysql_query("SELECT nompatient,ordo_num FROM patient AS p, ordonnance AS o WHERE p.numpatient = o.idpat GROUP BY ordo_num");
mysql_select_db('pharmacie') or die(mysql_error());
$resultfin = mysql_query($result);
//initialize counter
$i = 0;
//Set maximum rows per page
$max = 8;
//Set Row Height
$row_height = 35;
while($row = mysql_fetch_array($result))
{
//If the current row is the last one, create new page and print column title
if ($i == $max)
{
$pdf->AddPage();
$nompat = $row['nompatient'];
$ordonum = $row['ordo_num'];
$pdf->SetFillColor(232,232,232);
$pdf->SetFont('Arial','B',12);
$pdf->SetY($y_axis_initial);
$pdf->SetX(8);
$pdf->Cell(70,17.5,$nompat,1,0,'C',1);
$pdf->Ln(17.5);
$pdf->SetX(8);
$pdf->Cell(70,17.5,$ordonum,1,0,'C',1);
//Go to next row
$y_axis = $y_axis + $row_height;
//Set $i variable to 0 (first row)
$i = 0;
}
$nompat = $row['nompatient'];
$ordonum = $row['ordo_num'];
$pdf->SetFillColor(232,232,232);
$pdf->SetFont('Arial','B',12);
$pdf->SetY($y_axis);
$pdf->SetX(8);
$pdf->Cell(70,17.5,$nompat,1,0,'C',1);
$pdf->Ln(17.5);
$pdf->SetX(8);
$pdf->Cell(70,17.5,$ordonum,1,0,'C',1);
//Go to next row
$y_axis = $y_axis + $row_height;
$i = $i + 1;
}
//Create file
$pdf->Output();
?>
Je pense qu'il faudrait que je passe par un nouveau compteur pour le nombre de colonne quant on arrive à 3 je fait un Saut de ligne (Ln) et surement n autre compteur qui permettrait d'ajuster mon SetX (position de la cellule sur l'axe X) dans un Jolie SI Imbriqué.<?php
define('FPDF_FONTPATH','font/');
require('fpdf.php');
//Connect to your database
include("connec_pharma.php");
//Create new pdf file
$pdf=new FPDF('P','mm','A4');
//Open file
$pdf->Open();
//Disable automatic page break
$pdf->SetAutoPageBreak(false);
//Add first page
$pdf->AddPage();
//set initial y axis position per page
$y_axis_initial = 8;
$y_axis = 8;
//Select the Products you want to show in your PDF file
//$result=mysql_query("SELECT idpat,ordo_num FROM ordonnance GROUP BY ordo_num");
$result=mysql_query("SELECT nompatient,ordo_num FROM patient AS p, ordonnance AS o WHERE p.numpatient = o.idpat GROUP BY ordo_num");
mysql_select_db('pharmacie') or die(mysql_error());
$resultfin = mysql_query($result);
//initialize counter ligne
$i = 0;
//initialize counter cols
$cptcol = 0;
//Set maximum rows per page
$max = 8;
//Set maximim cols per page
$maxcol = 3;
//Set Row Height
$row_height = 35;
//Set Cols Width
$cols_width = 70;
while($row = mysql_fetch_array($result))
{
//If the current row is the last one, create new page and print column title
if ($i == $max)
{
$pdf->AddPage();
$nompat = $row['nompatient'];
$ordonum = $row['ordo_num'];
$pdf->SetFillColor(232,232,232);
$pdf->SetFont('Arial','B',12);
$pdf->SetY($y_axis_initial);
$pdf->SetX(8);
$pdf->Cell(70,17.5,$nompat,1,0,'C',1);
$pdf->Ln(17.5);
$pdf->SetX(8);
$pdf->Cell(70,17.5,$ordonum,1,0,'C',1);
//Go to next row
$y_axis = $y_axis + $row_height;
//Set $i variable to 0 (first row)
$i = 0;
}
if ($cptcol == 0)
{
$nompat = $row['nompatient'];
$ordonum = $row['ordo_num'];
$pdf->SetFillColor(232,232,232);
$pdf->SetFont('Arial','B',12);
$pdf->SetY($y_axis);
$pdf->SetX(8);
$pdf->Cell(70,17.5,$nompat,1,0,'C',1);
$pdf->Ln(17.5);
$pdf->SetX(8);
$pdf->Cell(70,17.5,$ordonum,1,0,'C',1);
//Go to next row
$cptcol = $cptcol + 1;
}
if ($cptcol == 1)
{
$nompat = $row['nompatient'];
$ordonum = $row['ordo_num'];
$pdf->SetFillColor(232,232,232);
$pdf->SetFont('Arial','B',12);
$pdf->SetY($y_axis);
$pdf->SetX(78);
$pdf->Cell(70,17.5,$nompat,1,0,'C',1);
$pdf->Ln(17.5);
$pdf->SetX(78);
$pdf->Cell(70,17.5,$ordonum,1,0,'C',1);
//Go to next row
$cptcol = $cptcol + 1;
}
if ($cptcol == 2)
{
$nompat = $row['nompatient'];
$ordonum = $row['ordo_num'];
$pdf->SetFillColor(232,232,232);
$pdf->SetFont('Arial','B',12);
$pdf->SetY($y_axis);
$pdf->SetX(148);
$pdf->Cell(70,17.5,$nompat,1,0,'C',1);
$pdf->Ln(17.5);
$pdf->SetX(148);
$pdf->Cell(70,17.5,$ordonum,1,0,'C',1);
//Go to next row
$y_axis = $y_axis + $row_height;
$i = $i + 1;
$cptcol = 0;
}
}
//Create file
$pdf->Output();
?>
Encore une fois je suis conscient que le résultat affiché (la redondance est logique) mais j'essaye depuis 3 Hrs de modifier cela sans la redondance mais j'y arrive pas.<?php
//PDF USING MULTIPLE PAGES
//FILE CREATED BY: Carlos José Vásquez Sáez
//YOU CAN CONTACT ME: [email protected]
//FROM PUNTA ARENAS, MAGALLANES
//INOVO GROUP - http://www.inovo.cl
define('FPDF_FONTPATH','font/');
require('fpdf.php');
//Connect to your database
include("connec_pharma.php");
//Create new pdf file
$pdf=new FPDF('P','mm','A4');
//Open file
$pdf->Open();
//Disable automatic page break
$pdf->SetAutoPageBreak(false);
//Add first page
$pdf->AddPage();
//set initial y axis position per page
$y_axis_initial = 8;
$y_axis = 8;
//Select the Products you want to show in your PDF file
//$result=mysql_query("SELECT idpat,ordo_num FROM ordonnance GROUP BY ordo_num");
$result=mysql_query("SELECT nompatient,ordo_num FROM patient AS p, ordonnance AS o WHERE p.numpatient = o.idpat GROUP BY ordo_num");
mysql_select_db('pharmacie') or die(mysql_error());
$resultfin = mysql_query($result);
//initialize counter ligne
$i = 0;
//initialize counter cols
$cptcol = 0;
//Set maximum rows per page
$max = 8;
//Set maximim cols per page
$maxcol = 3;
//Set Row Height
$row_height = 35;
//Set Cols Width
$cols_width = 0;
while($row = mysql_fetch_array($result))
{
//If the current row is the last one, create new page and print column title
if ($i == $max)
{
$pdf->AddPage();
$nompat = $row['nompatient'];
$ordonum = $row['ordo_num'];
$pdf->SetFillColor(232,232,232);
$pdf->SetFont('Arial','B',12);
$pdf->SetY($y_axis_initial);
$pdf->SetX(8);
$pdf->Cell(70,17.5,$nompat,1,0,'C',1);
$pdf->Ln(17.5);
$pdf->SetX(8);
$pdf->Cell(70,17.5,$ordonum,1,0,'C',1);
//Go to next row
$y_axis = $y_axis + $row_height;
//Set $i variable to 0 (first row)
$i = 0;
}
if (cptcol == 1)
{
$cols_width = 70;
$cptcol = $cptcol + 1;
}
if (cptcol == 2)
{
$cols_width = 140;
$cptcol = $cptcol + 1;
}
$cols_width = 1;
$nompat = $row['nompatient'];
$ordonum = $row['ordo_num'];
$pdf->SetFillColor(232,232,232);
$pdf->SetFont('Arial','B',12);
$pdf->SetY($y_axis);
$pdf->SetX(8 + $cols_width);
$pdf->Cell(70,17.5,$nompat,1,0,'C',1);
$pdf->Ln(17.5);
$pdf->SetX(8 + $cols_width);
$pdf->Cell(70,17.5,$ordonum,1,0,'C',1);
//Go to next row
$y_axis = $y_axis + $row_height;
$i = $i + 1;
}
//Create file
$pdf->Output();
?>
VOili Voilou je need à mort un petit coup de pouce sur cela je vous en serez trés reconnaissant. Merci d'avance.
if ($cptcol == 1)
{
$row = mysql_fetch_array($result);
$nompat = $row['nompatient'];
// [...]
if ($cptcol == 2)
{
$row = mysql_fetch_array($result);
$nompat = $row['nompatient'];
le fait de rappeler mysql_fetch_array() permet de récupérer le résultat suivant.