displaying query results as table

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

 



Hi,

I am querying a db table to return an array of months and teams that have
completed tasks in those months. Bascially it looks like [$month =>
$office_name] eg. [january => south office, january => north office,
february => south office]. I need to display this query in a table that
shows which offices have completed tasks for each month, like

January                    February
South Office            South Office
North Office

This might be a basic question, but I can't figure out how to group the
results so you only see the month one time, and then the list of all offices
with that month. Instead, I get

January
South Office

January
North Office

February
South Office

Can anyone help? Thank you. -Sam

Here's the code:

$result = @mysql_query($sql,$connection) or die
 ("Problem executing database query." . mysql_error());

 echo "<table width='500' border='0' cellspacing='0' cellpadding='2'
class='mainText'>";
 echo "<tr><td>";
 echo"<table border='1' cellpadding='2' cellspacing='0'
bordercolor='#FF9900'>\n";

 while ($row = mysql_fetch_array($result)) {

 $office_name = $row['office_name'];
 $month = $row['month'];

echo "<tr><td> $month<br>$office_name</td></tr>";

 } //close while loop
 echo "</table>\n";



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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux