0

hello everyone,

Help pls. I encounter "server error" with the last sql query statement in the last 'for' loop. Here is the code:

$qdev=mysql_query("select distinct(device) from wipdataperarea where creation_date like '$today%' and gtc='AL' order by gtc,device");

$device=mysql_num_rows($qdev);

while ($dev=mysql_fetch_assoc($qdev)) { 
  echo "<tr>";
  echo "<td>" . $dev['device']. "</td>";

 $qarea=mysql_query("select distinct(area2) from wipdataperarea where creation_date 
        like '$today%' and gtc='AL'"); 
 $result=mysql_num_rows($qarea);

    for ($i="0"; $i<($area=mysql_fetch_assoc($qarea)); $i++) {
       $query=mysql_query("select distinct(wip_pro), description from
                  wipdataperarea where creation_date like '$today%' and area2 = '" . 
                  $area['area2'] . "' and gtc='AL'");
       $count=mysql_num_rows($query);

        for ($x="0"; $x<($row=mysql_fetch_assoc($query)); $x++) {
           $sql=mysql_query("select count from wipdataperarea where 
                        creation_date like '$today%' and device = '" . $dev['device'] . 
                        "' and area2 = '" . $area['area2'] . "' and wip_pro = '" . 
                        $row['wip_pro'] . "' and description = '" .  
                        $row['description'] . "' and gtc='AL'");
           $cnt=mysql_num_rows($sql);

            for ($y="0"; $y<($count=mysql_fetch_assoc($sql)); $y++) {
                echo "<td>" . $count['count']. "</td>";
            }   


        }       
    }
                        echo "</tr>";

}
echo "</tr>";

Edited by mike_2000_17: Fixed formatting

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by cecille1127
0

It seems to me the problem might lie in the use of the for loops (are you sure about their ending condition?). Why not stick with while loops? You're not actually using the $i, $x and $y variables, are you?

0

It seems to me the problem might lie in the use of the for loops (are you sure about their ending condition?). Why not stick with while loops? You're not actually using the $i, $x and $y variables, are you?

hello dafnalia, thanks for responding
before i used the for loops, i already used while loop, in the same format, but to no avail.
when i used the while loops, i tested the loop by echoing the sql statement, and the sql statement was displayed according to the loop. but when i was trying to get the $count, internal server error occurs.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.