简体   繁体   中英

While loop for TCPDF

I have problem to loop the data in TCPDF..The output should be display like this

Output :

 Chair x 3 
 Table x 5 
 LCD  X 2

but output now just show : Chair x 3

It only display the first record. Can anyone explain how to loop the data based on output above?

$result_1=mysql_query($query_1);
   while($row1=mysql_fetch_array($result_1)){
     $item = $row1['item'];
     $qty = $row1['SUM(qty)'];            
     $data = $item.' x '.$qty;    
     $tbl.='<td align="center">'.$data.'</td>';       
     $data='';
   }
$tbl.='</tr>';
}

This picture output I get based on coding above

This is answer for my question. I just add $data. at

$data = $item.' x '.$qty;

and my problem has been solved.

    $result_1=mysql_query($query_1);
    while($row1=mysql_fetch_array($result_1)){

        $item = $row1['item'];
        $qty = $row1['SUM(qty)'];

    $data =  $data.$item.' x '.$qty.'<br>';  

    }
   $tbl.='<td align="center">'.$data.'</td>';
   $data='';
$tbl.='</tr>';
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM