echo detail array then summary array

Array $list is a list of items from a query and array $summary is a summary of that list (count, sum, etc). I echo each array to a table. I want to echo $summary array below the $list array. However $summary always appears to the right of $list. No matter how I use \n or
or

I can’t get it to echo on a new line. How do you do that? code is below.

$depositdate = $_POST[“date”];

echo “Date = “,$depositdate,”
”;

$list = mysql_query(“SELECT BankDepDate, UnitNo, LastName, Payments
FROM v_transactions
WHERE Payments >0 AND BankDepDate = ‘$depositdate’”);

echo ‘

’;
echo ’';
echo '';

while ($row = mysql_fetch_array($list)) {
echo "

";}

echo “
”;

$summary = mysql_query(“SELECT DISTINCTROW BankDepDate, SUM(Payments), COUNT(*)
FROM v_transactions
WHERE Payments >0 AND BankDepDate = ‘$depositdate’
GROUP BY BankDepDate”);

echo ‘

Date Unit Name Amount
$row[0] $row[1] $row[2] $row[3]
’;
echo ’';
echo '';

while ($row = mysql_fetch_array($summary)) {
echo "

";}

?>

Date Sum of Payments Count of Payments
$row[0] $row[1] $row[2]

You have problem in your HTML code, not PHP. First - missing closing tag. So, you’re starting to output second table, but you did not close the first table. Next, you are missing closing tag (in two places), see all lines line this:
[php]echo ’

';[/php]

Some of browsers would close this

for you properly, but generally speaking this is a bug. It is good practice to close all the tags such as , ,

etc. Not speaking of

and
- if you not close one of these, your page will break :slight_smile:

great, you found the problem. It’s working fine now. Thank you for your help.

Sponsor our Newsletter | Privacy Policy | Terms of Service