My table Pages_CSS looks like this:
Key int(11)
ClassID text
Content longtext
The query would look something like this:
$query_Style = "SELECT ClassID, Content FROM Pages_CSS";
$Style = mysql_query($query_Style);
$row_Style = mysql_fetch_assoc($Style);
ClassIDs will be repeated in the table. Content might be repeated as well. I want the output to have each Content grouped under ClassID, without ClassIDs being repeated. In other words, I want it formatted like this:
.ClassID1
Content
Content
.ClassID2
Content
Content
Another forum member suggested that I:
compar[e] the value of the current row's ClassID attribute to the row that you previously outputted. In order to access the latter, you simply need to store it in a temporary variable before the end of the loop and use that stored value for the comparison.
I realize though, that I can't just compare the current row with the previous row. I need to compare the current row with all previous echoed rows. Something like this in a "while" loop:
if(($AnyPreviousEchoedRow['ClassID'])==($CurrentRow['ClassID']))
{ $ClassID='';}
else $ClassID=$CurrentRow['ClassID'];
echo $ClassID;
I think what I need here is an array based on what ClassIDs have already been outputted. Can someone confirm whether that's the case?
Thanks for any help.