en ikke så køn løsning med det virker tilsyneladende, med den udskrift du vil have
jeg var desværrer nød til at lave 2 sql kald
ser frem til at se en pænere løsning
test data
CREATE TABLE IF NOT EXISTS `logs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`time` datetime NOT NULL,
`browser` text COLLATE utf8_danish_ci NOT NULL,
`ip` varchar(50) COLLATE utf8_danish_ci NOT NULL,
`action` text COLLATE utf8_danish_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_danish_ci AUTO_INCREMENT=9 ;
--
-- Data dump for tabellen `logs`
--
INSERT INTO `logs` (`id`, `time`, `browser`, `ip`, `action`) VALUES
(1, '2014-10-28 13:19:52', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10) AppleWebKit/600.1.25 (KHTML, like Gecko) Version/8.0 Safari/600.1.25', '87.104.102.143', 'Start cronjob'),
(2, '2014-10-28 13:19:52', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10) AppleWebKit/600.1.25 (KHTML, like Gecko) Version/8.0 Safari/600.1.25', '87.104.102.143', 'Der blev afsendt 0 reminder emails'),
(3, '2014-10-28 13:19:52', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10) AppleWebKit/600.1.25 (KHTML, like Gecko) Version/8.0 Safari/600.1.25', '87.104.102.143', 'Der blev slettet 0 timelønnet ansøgninger der er blevet kaldt til samtale'),
(4, '2014-10-28 13:19:52', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10) AppleWebKit/600.1.25 (KHTML, like Gecko) Version/8.0 Safari/600.1.25', '87.104.102.143', 'Der blev slettet 0 timelønnet ansøgninger'),
(5, '2014-10-28 13:19:52', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10) AppleWebKit/600.1.25 (KHTML, like Gecko) Version/8.0 Safari/600.1.25', '87.104.102.143', 'Der blev slettet 0 funktionær ansøgninger'),
(6, '2014-10-28 13:19:52', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10) AppleWebKit/600.1.25 (KHTML, like Gecko) Version/8.0 Safari/600.1.25', '87.104.102.143', 'Der blev slettet 0 funktionær ansøgninger der er kaldt til samtale'),
(7, '2014-10-28 13:19:52', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10) AppleWebKit/600.1.25 (KHTML, like Gecko) Version/8.0 Safari/600.1.25', '87.104.102.143', 'Cronjob afsluttet'),
(8, '2014-10-28 00:00:00', 'Firefox', '8.8.8.8', 'Google DNS kaldt');
<?php
$conn = MySqlPdo();
$logs = array();
$sql = "SELECT id, `time` FROM logs GROUP BY time ORDER BY `time` DESC ";
$rs = $conn->query($sql) or die(var_export($conn->errorinfo(), TRUE));
while ($obj = $rs->fetch(PDO::FETCH_OBJ)) {
$ar = array();
$logs['time'][] = $obj->time;
$logs['id'][] = $obj->id;
$sql1 = "SELECT * FROM logs WHERE time = '$obj->time'";
$rs1 = $conn->query($sql1) or die(var_export($conn->errorinfo(), TRUE));
while ($obj1 = $rs1->fetch(PDO::FETCH_OBJ)) {
$ar['ip'][] = $obj1->ip;
$ar['browser'][] = $obj1->browser;
$ar['action'][] = $obj1->action;
}
$logs['info'][] = $ar;
}
// print_r($logs);
$str = "<table>\n";
$str.="<tr>\n";
$str.="<th> id</th>\n";
$str.="<th> dato tid</th>\n";
$str.="<th>ip</th>\n";
$str.="<th>browser</th>\n";
$str.="<th>action</th>\n";
$str.="</tr>\n";
for ($i = 0, $lng = count($logs['time']); $i < $lng; $i++) {
$str.="<tr>\n";
$str.="<td>" . $logs['id'][$i] . "</td>\n";
$str.="<td>" . $logs['time'][$i] . "</td>\n";
// ip
$str.="<td>\n";
for ($j = 0, $lngj = count($logs['info'][$i]['ip']); $j < $lngj; $j++) {
$str.=$logs['info'][$i]['ip'][$j] . "<br/>\n";
}
$str = substr($str, 0, strlen($str)-6);
$str.="</td>\n";
// browser
$str.="<td>\n";
for ($j = 0, $lngj = count($logs['info'][$i]['browser']); $j < $lngj; $j++) {
$str.=$logs['info'][$i]['browser'][$j] . "<br/>\n";
}
$str = substr($str, 0, strlen($str)-6);
$str.="</td>\n";
// action
$str.="<td>\n";
for ($j = 0, $lngj = count($logs['info'][$i]['action']); $j < $lngj; $j++) {
$str.=$logs['info'][$i]['action'][$j] . "<br/>\n";
}
$str = substr($str, 0, strlen($str)-6);
$str.="</td>\n";
$str.="</tr>\n";
}
$str.="</table>";
echo $str;
?>