$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 ...
trtag. The lastif(where "3 equals 3") should be</tr>. Also lackingelsebranches. 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