Matching arrays to build tables (Solved)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I got a very modest email from Bill Baron with the following code which
works absolutely perfectly even though Bill never tested it! (Slick!).
Thank's a million for that Bill and also thanks to Svensson for all the
help - very much appreciated.  Here is the code which I modified ever so
slightly to work with an HTML table as opposed to the seperators I initially
asked for and Bill used. Hope it can be of use to others.

echo "<table border='1' cellpadding='0' cellspacing='1'>\n" .
        "<tr>\n";

$i=0;

$dayscount=count($days);

while ($i < $dayscount) {
    if (empty($outputdata[$days[$i]]['amount'])) {
    $outputdata[$days[$i]]['amount']=0;
    }

$outputdata[$days[$i]]['amount']+=$amount[$i];
$outputdata[$days[$i]]['code']=$code[$i];

++$i;
}

for ($i=0;$i<=15;$i++) {
echo "<td>" . $i . "</td><td bgcolor='silver'>";
    if (!empty($outputdata[$i]['amount'])) {
        echo $outputdata[$i]['amount'];
    }

echo "</td>\n";

if (!empty($outputdata[$i]['code'])) {
    echo $outputdata[$i]['code'];
}
echo "</tr>\n";
}

echo "</table>";

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux