从数据库中选择记录:
$dados = mysql_query($query_dados, $valesilveira) or die(mysql_error());
# $totalRows_dados = mysql_num_rows($dados); # you don't need this unless you're using
# $totalRows_dados somewhere else
# check for number of results. If there are none, exit / die / return / whatever
if (mysql_num_rows($dados) == 0) {
echo "no results found!";
# die / exit / return false / etc.
}
# initialise a string to hold the articles
$articles = '';
# loop through the results one at a time
while ($row_dados = mysql_fetch_assoc($dados)) {
# append the article div on to our existing string
$articles .= '
<div id="articles">
<div class="titulobold"><p> '.$row_dados['titulo'].'</p></div>
<div class="wid10"><p>'.$row_dados['posicao'].'</p></div>
<div class="wid15"><p><img src="images/artigos/'.$row_dados['folder'].'/'.$row_dados['id_artigo'].'.png" style="height:60px;" /></p></div>
<div class="wid30"><p> '.$row_dados['desc'].'</p></div>
<div class="wid15"><p>'. number_format( $row_dados['unitario'], 2 ) .'€</p></div>
<div class="wid15"><p>'. number_format( $row_dados['unitario']*$row_dados['quantidade'], 2 ) .'€</p></div>
<div class="wid10"><p>'.$row_dados['quantidade'].'</p></div>
</div>
';
// any other stuff you want to do to each piece of row data can go here
}
但由于某些原因,我的工作并不像我想要的那样,因为在每一页中,记录都会开始上升,但是有了更多信息的图像会出现错误:
http://i.imgur.com/TEv0GNj.jpg - Page 1
http://i.imgur.com/8Z1WBqR.jpg - Page 2
http://i.imgur.com/iMtX4fU.jpg - Page 3
它继续像一个循环一样上升。
请告诉我该怎么做。
其余代码:
//==============================================================
//==============================================================
//==============================================================
include("mpdf.php");
$mpdf=new mPDF('c','A4','','',15,15,139,28,9,9);
$mpdf->SetDisplayMode('fullpage');
$mpdf->SetHTMLHeader($header);
$mpdf->SetHTMLFooter($footer);
// LOAD a stylesheet
$stylesheet = file_get_contents('css/print.css');
$mpdf->WriteHTML($stylesheet,1); // The parameter 1 tells that this is css/style only and no body/html/text
$mpdf->WriteHTML($articles);
$mpdf->Output();
exit;
//==============================================================
//==============================================================
//==============================================================