I have this php code:
$query_production = \"SELECT uploadedby as name, sum(points) as points,
date_format(uploaddate,\'%Y-%m-%d\') as date FROM imsexport
WHERE
This will get you most of the way there; what I've left to you is how to get the left offset correct (or the date/points column alignment; hint, you'll need to keep the date with the name/points pair and know it's offset in $cols
).
Obviously you're dealing with rows out of a database, so it'll be a little bit different.
See the codepad demo link below the code.
$date, 'points' => $points));
}
$cols = array_unique($cols);
print_r($pivot);
echo implode('|', $cols);
echo PHP_EOL;
foreach ($pivot as $name => $row) {
while ($entry = array_shift($row)) {
echo str_pad($name, 7, ' ') . str_pad($entry['points'], 3, ' ', STR_PAD_LEFT) . '|';
}
echo PHP_EOL;
}
?>
http://codepad.org/WqqpKwn3