> From: Ing. Rajesh Kumar [mailto:[EMAIL PROTECTED]] 
> Sent: Thursday, August 15, 2002 9:36 AM
> Subject: [PHP] How to show data in one row from two rows from 
> the database
> Hi everybody
> What I wrote in the subject may look complicated so I added a 
> html file. It
> explains what I have and what I want to show.
> Thanks in advance
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'];
             'OFFPEAK': $offpeak = $row3['TARIFF'];
    echo "{$row2['GROUP']} {$row3['TIME']} {$row3['TARIFF']}<br>\n";


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

Reply via email to