I have search and implements from many question in stackoverflow to my code but it always returning only the last row value. Here my code :
$totalpayment = 0;
foreach($respon2 as $key => $row) {
$name = $row['title'];
$quantity = $row['quantity'];
$price = $row['price']*$row['quantity'];
$totalpayment += $price;
$price = '$ ' . number_format($price) ;
$totalpayment = '$ ' . number_format($totalpayment) ;
$mytable .= '<tr width="100%">';
$mytable .= '<td width="55%" align="left">' . $name . "</td>";
$mytable .= '<td width="20%" align="right">' . $quantity . "</td>";
$mytable .= '<td width="25%" align="right">' . $price . "</td>";
$mytable .= '</tr>';
}
$mytable .= '</table>';
$mytable .= '<table border="0" cellpadding="10" cellspacing="0" width="100%%" style="padding: 0px 25px 0px 25px;">';
$mytable .= '<tr><td width="45%"></td><td width="30%" class="table-title" align="right">Total Payment:</td><td width="25%" align="right">'. $totalpayment ."</td></tr>";
$mytable .= '</table>';
How to fix this ?