$output[] = '
'; $output[] = ''; foreach ($contents as $id=>$qty) { $sql = 'SELECT * FROM books WHERE id = '.$id; $result = $db->query($sql); $row = $result->fetch(); extract($row); $output[] = ''; $output[] = ''; $output[] = ''; $output[] = ''; $output[] = ''; $output[] = ''; $total += $price * $qty; $output[] = ''; } $output[] = '
Remove'.$title.' by '.$author.'£'.$price.'£'.($price * $qty).'
'; $output[] = '

Grand total: £'.$total.'

'; $output[] = '
'; $output[] = '
';