Very simple procedurally (though not in SQL). Here's the pseudo-code: Execute: SELECT * FROM Y WHERE U = 'me' ORDER BY Y, X $flag = "last_y" ; // flag indicating whether or not your mysql_fetch_array() brings a new value of Y Loop your query result { if Y <> $flag['last_y'] { // this is a new value of Y: trigger a HTML header row // update $flag['last_y'] = Y } // generate the normal HTML row } HTH Ignatius ____________________________________________ ----- Original Message ----- From: "Victor" <victor@argilent.com> To: <php-general@lists.php.net> Cc: <php-db@lists.php.net> Sent: Monday, December 02, 2002 8:53 AM Subject: some data output formatting and grouping question... > I just have a fucking mental block; I cannot at all conceive the > necessary syntax to or even the theoretical algorithm that I need, to do > the following: > > Consider the following table: > > U | X | Y > --|---|-- > me|001|0a > me|002|0a > me|003|0a > me|002|0b > me|003|0b > me|004|0b > ..|...|.. > > then the code says: > > SELECT * FROM Y WHERE U = me > > So now what? > - remember I do not know the value of Y, so it has to be an automatic > thing; I can't just say ... WHERE U = me AND Y = a. > > I want this output: > > 0a > 001 > 002 > 003 > _______________________ (<hr>) > > 0b > 002 > 003 > 004 > > How the hell do I do that? I can't think of the goddamn' syntax! > > ______________________________________________________________________ > Post your free ad now! http://personals.yahoo.ca > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php