Thanks to both Aron and Mr Crouch for their help... Aron suggested three separate queries, which was a thought I had originally, but as I was about to implement that idea, with the extra code that required Mr Crouch came along with his 'test' variable idea. The code I used is at the end of this post.
With the information supplied (and a little bug checking of my own) I am able to say that I have succeeded in placing an <hr> above the first entry of a 'dishtype' group, not exactly what I wanted, but light years ahead of where I was. If anyone knows how to place it at the bottom (or after) the LAST item of a group I would be most indebted. Below is the reworked code that I used incorporating the ideas that Matthew sent along, as a closing statement on my question: ------------------------- while ($a_row = mysql_fetch_array ($result) ) { //strip slashes so input appears correctly $a_row[name] = stripslashes ($a_row[name]); $a_row[shorttext] = stripslashes($a_row[shorttext]); if ($a_row[dishtype] != $loop) { echo "<hr size=\"1\" width=\"30%\" noshade>\n"; \\the required <hr> tag } //here I placed more information about the dish $loop=$a_row[dishtype]; } -------------------------- Thanks a lot guys Keiran ---- Matthew Crouch <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED].; > Another way is to set a testing variable and then print an <hr> if it > changes > (this off the top of my head, probably bugs in it but you get the idea) > > while $myrow=mysql_fetch_row($result) { > if $myrow["dishtype"]<>$test { > echo "<hr>"; > //here you would print the rest of the info about the dish from the row > } > $test=$myrow["dishtype"]; > } > > Keiran Wynyard wrote: > > > I need to loop through a grouped recordset adding a <hr> at the > > end of each group, how can groups in recordsets be identified in > > PHP for specific formatting. > > > > SELECT name AS name, dishtype AS dishtype, price AS price > > FROM dishes > > WHERE used = 1 > > GROUP BY dishtype, name > > ORDER BY dishtype, price DESC > > > > The use is in the display of a menu for a restaurant, where there > > is a table containing all the dishes on the menu in any given > > instance, but they musst be displayed in a specific order, > > grouped by type. In other words, all Starters come first, > > followed by Main courses, followed by Desserts. Between each type > > there needs to be a seperator, the horizontal line. > > > > Thanks for you help > > > > Keiran > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php