Hi,
Ok I have a table that contains all of my content for a particular section, each item added to this table has a category name assigned to it so I know what it actually belongs to.
So I want to pull out everything of categoryX and then everything of categoryY.
Now, this is my query:
$query = "
SELECT tbl_content.fld_ID,
TRIM(tbl_content.fld_Title) as fld_Title,
tbl_content.fld_Category
FROM tbl_content
WHERE
(
(tbl_content.fld_Category like 'newsletter') or
(tbl_content.fld_Category like 'publication')
)
ORDER BY tbl_content.fld_ID DESC
";
So as usual I am using a while loop to iterate through my results and output them. Problem is, it orders them by the fld_ID field which is fair enough, I told it to. But I want it to list all newsletters items, then all publication items...
Now, to complicate it further - I need a "Newsletters" heading and a "Publications" heading above each relavant section. So I can't do it like this:
<?
// iterate through resultset
while($row = mysql_fetch_object($result))
{
if ($row->fld_Category == "newsletter"){
?>
<h1>Newsletters</h1>
<p>Item Name</p>
<? } else if ($row->fld_Category == "publication") { ?>
<h1>Publications</h1>
<p>Item Name</p>
<?
}
}
?>
Any ideas on how I seperate this data without using two queries? That seems the simplest thing to me, but there must be a better way to do this.
Cheers,
Chris