Re: FW: PHP Question on MySQL grouping
| From: | Matthew Crouch | Date: | Fri, 01 Mar 2002 23:39:52 +0000 |
| Subject: | Re: FW: PHP Question on MySQL grouping | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-17400@lists.php.net to get a copy of this message | ||
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