TCPDF - printing table from mysql

前端 未结 4 1133
情书的邮戳
情书的邮戳 2021-01-01 01:19

in my php,

while($info3 = mysql_fetch_array($result3)){
$Name = $info3[\"Name\"];
$Address = $info3[\"Address\"];
$Age = $info3[\"Age\"];
// ----------------         


        
4条回答
  •  长发绾君心
    2021-01-01 01:55

    I would certainly do something like this:

    $table = '%s
    ' $tr = ' %s %s %s '; while($info3 = = mysql_fetch_array($result3)){ $trs[] = sprintf($tr, $info3["Name"], $info3["Age"], $info3["Address"]); } $tbl = sprintf($table, implode( $trs )); $pdf->writeHTML($tbl, true, false, false, false, '');

    If you can't organize your presentation layer with templates at least make it as separated as you can from the actual logic.

    You can read about sprintf here and implode here

提交回复
热议问题