Re: Group date with category

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux