[snip]
Something like:

$sql = "Select DISTINCT COUNTRY from tariffs";
$result=mysql_query($sql) or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
  echo "Rates for {$row['COUNTRY']}<br>\n";
  $sql = "select DISTINCT GROUP from tariffs where
COUNTRY='{$row['COUNTRY']}' order by GROUP";
  $result2=mysql_query($sql) or die(mysql_error();
  while ($row2 = mysql_fetch_array($result)) {
    $sql = "select TIME,TARIFF from tariffs where
COUNTRY='{$row['COUNTRY']}' and GROUP='{$row2['GROUP']}' order by TIME
DESC";
    $result3=mysql_query($sql) or die(mysql_error();
    $peak ='&nbsp';
    $offpeak = '&nbsp;';
    while ($row3 = mysql_fetch_array($result3)) {
      switch (strtoupper($row3['TIME'])) {
             'PEAK': $peak = $row3['TARIFF'];
                    break;
             'OFFPEAK': $offpeak = $row3['TARIFF'];
                       break;
      }
    }
    echo "{$row2['GROUP']} {$row3['TIME']} {$row3['TARIFF']}<br>\n";
  }

}
[/snip]

Actually it can be handled as a CROSSTAB query in SQL without any PHP
code(save for forming your tables). Have a look at this article,
http://www.mysql.com/articles/wizard/index.html .

HTH!

Jay

I’m the man of this house and I have my wife’s permission to say so

***********************************************************
* Texas PHP Developers Conf  Spring 2003                  *
* T Bar M Resort & Conference Center                      *
* New Braunfels, Texas                                    *
* San Antonio Area PHP Developers Group                   *
* Interested? Contact [EMAIL PROTECTED] *
***********************************************************
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





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

Reply via email to