Re: Group date with category

From: Date: Mon, 22 May 2006 20:05:40 +0000
Subject: Re: Group date with category
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-236661@lists.php.net to get a copy of this message
On Mon, May 22, 2006 6:53 am, Jonas Rosling wrote: > Anyone know any good why to group date in a recordset in any good way? > As if > you categorize it in columns. Like: > > Category 1 > Row1 -> Data Data > Row2 -> Data Data > Row3 -> Data Data > > Category 2 > Row1 -> Data Date > Row2 -> Data Data > Row3 -> Data Data $query = 'SELECT category, row, data FROM whatever ORDER BY category, row, data'; $info = @mysql_query($query, $connection) or trigger_error(mysql_error(), E_USER_NOTICE); $last_category = ''; while (list($category, $row, $data) = mysql_fetch_row($info)){ if ($last_category != $category){ echo "$category<br />\n"; $last_category = $category; } echo "$row -> $data<br />\n"; } -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#236661) next »