On Sun, 2007-08-12 at 08:07 +1000, Kevin Waterson wrote:
> I wish to get a result set into a html table.
> normally this is not a problem. 
> But I wish to use one of the results as a heading.
> 
> Here is the data... ASCII art warning
> +----------------+------------------+-----------------+---------------+
> | forum_group_id | forum_group_name | forum_type_name | forum_type_id |
> +----------------+------------------+-----------------+---------------+
> |              1 | Administration   | Photography     |             1 |
> |              1 | Administration   | Site Issues     |             3 |
> |              1 | Administration   | Test            |             4 |
> |              2 | General          | Modelling       |             2 |
> |              2 | General          | foo             |            10 |
> |              2 | General          | bar             |            11 |
> +----------------+------------------+-----------------+---------------+
> The goal is to produce HTML tables like this..
> +----------------+
> | Adninistration |
> +----------------+
> | Photography    |
> +----------------+
> | Site Issues    |
> +----------------+
> |    Test        |
> +----------------+
> +----------------+
> |   General      |
> +----------------+
> |  Modelling     |
> +----------------+
> |     foo        |
> +----------------+
> |     Bar        |
> +----------------+

<?php

$data = array();
while( ($row = mysql_fetch_assoc( $result )) )
{               
    $data[$result['forum_group_name']][] = $result;
}                                                  

foreach( $data as $forumName => $types )    
{                                        
    echo '<table>'
        .'<tr>'
        .'<th>'
        .$forumName
        .'</th>'
        .'</tr>';
 
    foreach( $types as $type )
    {
        echo '<table>'
            .'<tr>'
            .'<td>'
            .$type['forum_type_name']       
            .'</td>'
            .'</tr>';
    }   
 
    echo '</table>';
}

?>

Cheers,
Rob.
-- 
...........................................................
SwarmBuy.com - http://www.swarmbuy.com

    Leveraging the buying power of the masses!
...........................................................

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

Reply via email to