$x=0; $y=0; while ($resilt = mysql_fetch_array($query)){ //пройдемся по циклу $x < $resilt; $x++; //номер по порядку if ($z==0) //если осталось 0 строк, значит считаем кол-во строк { $que = mysql_query("SELECT COUNT(id_kvita) FROM kvitanc WHERE zakryt='1'");//считаем, сколько строк содержит запись $re=mysql_fetch_array($que); $y=$re[0]; //например 3 раза $x=$re[0]; } echo" <tr height=28px;> <td>{$x})</td> <td>{$resilt[1]}</td> <td>{$resilt[2]}</td> <td>{$resilt[3]}</td> <td>{$resilt[4]}</td> <td>{$resilt[5]}</td> <td>{$resilt[6]}</td> <td>{$resilt[7]}</td> "; if ($y==$z) //если 3 равно 3 { $z=$z-1; //отнимаем единицу echo "<td rowspan='".$y."' Редактировать № {$resilt[8]}</td><tr>"; //объединяем 3 ячейки } elseif ($z!==0) //если 2 не равно нулю { $z=$z-1; //отнимаем единицу echo "<tr>"; //еще одного TD нет, просто новая строка } } 

So, with the help of rewspan you need to merge the last column, but the markup is not correct, combines 2 of 3 lines, or 2 of 4 ...

  • Some very strange comments. - Arnial
  • "id_kvita" is a non-unique number, it can coincide on each line, and if it matches the previous one, then the previous <td> </ td> cell is merged. More intelligent could not come up with (( - Samoylenko Alexandr
  • You never close the tr tag. The last if (where "3 equals 3") should be </tr> . Also lacking else branches. By code it is difficult to understand whether there can be such that 3 is not equal to 3 and 2 is equal to 0, no matter how crazy it sounds. - Arnial
  • You are a genius!)) I did not even notice that tr is not closed. Closed - and everything fell into place) Well, the absence of the else branch means for me that just do not need to perform further. Or is it not right? - Samoylenko Alexandr
  • Ok, then I will create an answer, I'll write about else in the same place. - Arnial

1 answer 1

You never close the tr tag.

In the last if (where "3 equals 3"), it should be </tr> , similarly for elseif .

Also lacks an else branch that would guarantee the closure of tr .

For example, in the case when $z is equal to zero and $y is equal to 3, neither the last if or elseif fails, respectively, tr will not be closed.