I'm struggling to understand the syntax of for each/while loops in relation to MySQL queries.
I'm trying to output a list of dates that are grouped by year. I understand that I need a for each loop that contains a while statement...
for each -> 'year' -> list all dates.
I'm not even sure if the 'for each' needs to be a 'for each' (or a 'while').....I'm currently using a 'while' to get the dates list.
This is the code that I'm using to pull out the dates in an un-grouped list that I need to be part of the 'for each'...
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo [html containing date fields - {$row['year']}{$row['month']}{$row['day']} etc]}
};
I'm fairly happy with how to enclose this in an outer loop (year) - I'm just unsure of the syntax to make the outer loop act on the 'year' field.