My table "Pages_CSS" looks like this:
Key int(11)
ClassID text
Content longtext
It's a table that will output CSS, where "ClassID" is a CSS class or ID, and "Content a single CSS setting like "color: #FFFFFF". A ClassID may be repeated multiple times in the table, because I may have multiple pieces of Content for it.
Given the subject matter, naturally the format I want to output is:
ClassID1
Content
Content
ClassID2
Content
Content
The closest I got to output ordered as I would like was:
$query_Style = "SELECT DISTINCT ClassID from Pages_CSS UNION Select Content from Pages_CSS order by ClassID";
$Style = mysql_query($query_Style, $CollectionLocal) or die(mysql_error());
$row_Style = mysql_fetch_assoc($Style);
That yielded results like this:
ClassID1
ClassID2
Content
Content
Content
Content
In other words, the only thing it accomplished was avoiding repetition of ClassID1 and ClassID2 over and over, with each Content row.
Do I need to create two temporary tables and join them on ClassID? If so, can someone point me at an example where this is being done from data in a single table? Every example I'm finding involves multiple tables and that is confusing.
Thanks. 🙂