Hello all,
I have a query that gets all the record for a particular Subject (Economics Id=7 in this example), and I can get the Subject -> articles for them, but I am stuck trying to break them down into arrays that I can iterate through.
Here is the query:
SELECT DISTINCT
eos.EyeopenersId,
eos.SubjectId,
eot.Id AS eotId,
eot.`Name`,
eo.Id AS eoId,
eo.EyeOpenersTypeId AS eoTypeId,
eo.Title
FROM eyeopeners_subjects as eos
LEFT OUTER JOIN eyeopeners as eo
ON eos.EyeopenersId=eo.Id
LEFT OUTER JOIN eyeopenerstype as eot
ON eot.Id=eo.EyeOpenersTypeId
WHERE eos.SubjectId=7
ORDER BY Date ASC
Here is an example from that query.
What I am trying to display would be (from my example JPG link above):
Videos (the name of each category before the records for that category)
--- 1st Title
--- 2nd Title
--- 3rd Title
--- 4th Title
Infographics
--- 1st Title
Infographics2
--- 1st Title
Charts & Graphics
-- 1st Title
Here is my attempt to populate the arrays:
while ($row = mysql_fetch_array($result)) {
$eotId = $row['eotId'];
$eoId = $row['eoId'];
$Title = $row['Title'];
$name = $row['Name'];
$subject[$eotId]= $eoId;
$types[$eotId] = $subject;
}
But this returns an array that I couldn't figure out how to sort like my example above.
I tried to use this post from a similar question I had before, but I struggle with arrays and looping through them.
Thanks,
Don