Ich brauche eine Webseite, die eine PDF-Datei erzeugt, die mehrere Werte für dieselbe Zeile in einer sql db -Tabelle zurückgibt. Im Moment funktioniert es, da es die Ergebnisse liefert, die ich brauche, aber nur für die Tabellenreihe Nummer 1. Aber ich habe 1600+ Zeilen und ich hätte gerne die PDF mit allen Zeilen. (A4 pdf, mit 2 Ergebnissen pro Seite)FOR LOOP - brauchbare Unterstützung
-Code
<?php
require_once('include/menu.php');
include_once("mfpdf/mpdf.php");
include_once('include/ez_sql.inc');
setlocale(LC_MONETARY, 'pt_PT');
$socio = $db->get_results("SELECT * FROM socios where estado = 'ACTIVO'");
$mpdf=new mPDF('c','A4','','',32,25,27,25,16,13);
$mpdf->SetDisplayMode('fullpage');
$mpdf->list_indent_first_level = 0;
$mpdf -> allow_charset_conversion=true;
$mpdf->charset_in='utf-8';
// $stylesheet = file_get_contents('mfpdf/mpdfstyletables.css');
$mpdf->WriteHTML($stylesheet,1); // *** The parameter 1 tells that this is css/style only and no body/html/text
$cont = 0;
foreach ($socio as $socio1) {
$cont = $cont + 1;
$ano = date("Y");
$idade = age(dtPadrao($socio->nascimento));
if ($idade >= 18) $Vquota = 1.50;
else $Vquota = 1;
$Vquota = money_format('%.2n', $Vquota);
$html = '
<br /><br />
<table width="794px" height="462px" align="center" style="border: 0px solid #880000; background-color: #FFF; " class="tallcells">
<tr>
<td height="462px" width="250px" valign="top" align="left">
<br><br><img src="img/sfal_logo.png" height="140px"><br><br><br>
<table border="2px" align="center">
<tbody>
<tr>
<td align="left"><font size="5"><h3>SOCIO Nº '.$socio1->n_socio.'</h3><br />
'.$socio1->nome.'<br />
'.$socio1->morada.'<br />
'.$socio1->cod_postal.' - '.$socio1->localidade.'<br />
<br />Ano '.$ano.'<br />
Valor Mensal: '.$Vquota.'
<br /><br />
Local de Cobrança:<br />
'.$socio1->local_cobranca.'</font><br />
</td>
</tr>
</tbody>
</table>
</td>
<td width="544px"> <!-- was 10px 10px-->
<table cellpadding="0px" cellspacing="15px" align="center">
<tbody>
<tr>
<td style="border: 1px solid #880000; background-color: #FFF;" width="190px" class="tallcells" align="center"><font size="5">
SFAL
<br />Sócio n.: '.$socio1->n_socio.'
<br />Valor: '.$Vquota.'
<br />DEZEMBRO
<br />'.$ano.'</font></td>
<td style="border: 1px solid #880000; background-color: #FFF; " width="190px" class="tallcells" align="center"><font size="5">
SFAL
<br />Sócio n.: '.$socio1->n_socio.'
<br />Valor: '.$Vquota.'
<br />NOVEMBRO
<br />'.$ano.'</font></td>
<td style="border: 1px solid #880000; background-color: #FFF; " width="190px" class="tallcells" align="center"><font size="5">
SFAL
<br />Sócio n.: '.$socio1->n_socio.'
<br />Valor: '.$Vquota.'
<br />OUTUBRO
<br />'.$ano.'</font></td>
</tr>
<tr>
<td style="border: 1px solid #880000; background-color: #FFF; " class="tallcells" align="center"><font size="5">
SFAL
<br />Sócio n.: '.$socio1->n_socio.'
<br />Valor: '.$Vquota.'
<br />SETEMBRO
<br />'.$ano.'</font></td>
<td style="border: 1px solid #880000; background-color: #FFF; " class="tallcells" align="center"><font size="5">
SFAL
<br />Sócio n.: '.$socio1->n_socio.'
<br />Valor: '.$Vquota.'
<br />AGOSTO
<br />'.$ano.'</font></td>
<td style="border: 1px solid #880000; background-color: #FFF; " class="tallcells" align="center"><font size="5">
SFAL
<br />Sócio n.: '.$socio1->n_socio.'
<br />Valor: '.$Vquota.'
<br />JULHO
<br />'.$ano.'</font></td>
</tr>
<tr>
<td style="border: 1px solid #880000; background-color: #FFF; " class="tallcells" align="center"><font size="5">
SFAL
<br />Sócio n.: '.$socio1->n_socio.'
<br />Valor: '.$Vquota.'
<br />JUNHO
<br />'.$ano.'</font></td>
<td style="border: 1px solid #880000; background-color: #FFF; " class="tallcells" align="center"><font size="5">
SFAL
<br />Sócio n.: '.$socio1->n_socio.'
<br />Valor: '.$Vquota.'
<br />MAIO
<br />'.$ano.'</font></td>
<td style="border: 1px solid #880000; background-color: #FFF; " class="tallcells" align="center"><font size="5">
SFAL
<br />Sócio n.: '.$socio1->n_socio.'
<br />Valor: '.$Vquota.'
<br />ABRIL
<br />'.$ano.'</font></td>
</tr>
<tr>
<td style="border: 1px solid #880000; background-color: #FFF; " class="tallcells" align="center"><font size="5">
SFAL
<br />Sócio n.: '.$socio1->n_socio.'
<br />Valor: '.$Vquota.'
<br />MARÇO
<br />'.$ano.'</font></td>
<td style="border: 1px solid #880000; background-color: #FFF; " class="tallcells" align="center"><font size="5">
SFAL
<br />Sócio n.: '.$socio1->n_socio.'
<br />Valor: '.$Vquota.'
<br />FEVEREIRO
<br />'.$ano.'</font></td>
<td style="border: 1px solid #880000; background-color: #FFF; " class="tallcells" align="center"><font size="5">
SFAL
<br />Sócio n.: '.$socio1->n_socio.'
<br />Valor: '.$Vquota.'
<br />JANEIRO
<br />'.$ano.'</font></td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>
<br /><br /><br />
';
//==============================================================
//==============================================================
//==============================================================
// $html = mb_convert_encoding($html, 'UTF-8', 'UTF-8');
$mpdf->WriteHTML($html,2);
if ($cont == 50) break;
//==============================================================
//==============================================================
//==============================================================
}
$mpdf->Output('mpdf.pdf','I');
exit;
?>
Ihre Db-Schnittstelle sieht so aus: s zieht nur eine einzige Zeile: '$ db-> get_row'. Jeder kann Ihnen sagen, wie man eine Schleife implementiert, aber ohne Ihre DB-Klasse zu sehen, haben wir keine Möglichkeit zu wissen, wie Sie alle Datensätze aus der DB statt einer einzigen Zeile ziehen können. –
meine db-klasse? Entschuldigung, aber .. was meinst du ?! –
Ich meine die Datei: 'ez_sql.inc', die Ihre Datenbank-Interaktionen behandelt. Ich habe auf Github nachgeschaut, aber im Moment ist Github offline. –