Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I have a table in mysql, each item has a heading, a title, and a description. Some entries have the same heading but always a different title and description. I'd like to display it dynamically in a page like this:
HEADING
-------------
TITLE >> DESCRIPTION
TITLE >> DESCRIPTION
TITLE >> DESCRIPTION
-------------
HEADING
-------------
TITLE >> DESCRIPTION
TITLE >> DESCRIPTION
TITLE >> DESCRIPTION
-------------and so on...
What I'd like assistance with is learning how to display the heading once and then display all the results (titles and descriptions) that match the same heading, then repeat this process for each of the other items that match the other headings.Can anyone help? I know it's probably basic to many but I can figure it out and am having trouble finding assistance on the web that suits my needs.
Thanks in advance,
Martin

Language is php/MySQL.
I've since found this solution but if you have a better idea I'd be happy to hear about it.
$result = mysql_query("SELECT * FROM tablename ORDER BY heading");
$check = '';
while($r=mysql_fetch_object($result)){
if($check != $r->heading){
echo "$r->heading</p>";
$check = $r->heading;
}
echo "$r->title >> $r->description<br />";
}
?>

![]() |
Dynamically Creating Hype...
|
Finding broken links
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |