Dividing query results and displaying
Posted: Fri Jul 25, 2008 5:52 am
Hi there,
I've got a links page that lists all of the links in one big long list using a while loop:
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo '
<p><a href="'.$row['link_url'].'">' . $row['link_name'] .'</a></p>
<p>'.$row['link_description'].'</p><br />';
}
thats fine but I want to change it so that the links are divided up into categories.
At the moment I've done it the stupid way by having a seperate SELECT query for each category and then running the above code for each query.
Could someone tell me a better way?
What I want to end up with is a links page which has a title for each category followed by the links related to that cateogry. Pretty simple stuff.
Thanks in advance,
Wilbo
I've got a links page that lists all of the links in one big long list using a while loop:
while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
echo '
<p><a href="'.$row['link_url'].'">' . $row['link_name'] .'</a></p>
<p>'.$row['link_description'].'</p><br />';
}
thats fine but I want to change it so that the links are divided up into categories.
At the moment I've done it the stupid way by having a seperate SELECT query for each category and then running the above code for each query.
Could someone tell me a better way?
What I want to end up with is a links page which has a title for each category followed by the links related to that cateogry. Pretty simple stuff.
Thanks in advance,
Wilbo