PHP Code:
$db->query("SELECT ux.id as id, ux.exerciseid, ux.date as date, ux.notes, e.measurement, e.name
FROM `users exercises` ux LEFT JOIN exercises as e ON e.id = ux.exerciseid
WHERE `userid` = '$memberid'
ORDER BY date DESC LIMIT 20");
while($row = $db->fetch_assoc())
$aData[$row['id']] = array($row['date'], $row['id'], $row['name']);
print_r($aData);
This outputs:
PHP Code:
Array
(
[4] => Array
(
[0] => 2012-10-03 02:44:38
[1] => 4
[2] => Double Kettlebell Press
)
[3] => Array
(
[0] => 2012-10-03 02:11:13
[1] => 3
[2] => Elliptical Trainer
)
[2] => Array
(
[0] => 2012-10-03 01:59:46
[1] => 2
[2] => Fencing
)
[1] => Array
(
[0] => 2012-08-29 16:14:14
[1] => 1
[2] => Other Dancing
)
)
However I'm trying to nest the array by day:
PHP Code:
Array
(
[2012-10-03] => Array
(
[3] => Array
(
[0] => 2012-10-03 02:11:13
[1] => 3
[2] => Elliptical Trainer
)
[2] => Array
(
[0] => 2012-10-03 01:59:46
[1] => 2
[2] => Fencing
)
[1] => Array
(
[0] => 2012-10-03 02:44:38
[1] => 4
[2] => Double Kettlebell Press
)
)
[2012-10-02] => Array
(
[1] => Array
(
[0] => 2012-08-29 16:14:14
[1] => 1
[2] => Other Dancing
)
)
)
Any idea?