私はIDと名前で構成されるデータベースからレコードを持っています。すべてのレコードが1-2-1-2-4のように分散されているcolspanに出力します。次のようにhttp://imageshack.us/photo/my-images/42/wrongb.png/を与える私のプログラムリストは次のとおりです。colspanのphp表示レコード
<table border="1" cellspacing="0" cellpadding="0" width="200">
$itemCount = 0;
$itemIndex = 0;
$colSpan = 0;
$itemColCount = 0;
while ($itemCount < $total) { // $row = mysql_fetch_array($result)
$row = mysql_fetch_array($result)
<tr>
if ($itemIndex == 0 || $itemIndex == 2)
{
$colSpan=4;
$itemColCount = 1;
$itemIndex++;
}
else if ($itemIndex == 1 || $itemIndex == 3) {
$colSpan=2;
$itemColCount = 2;
$itemIndex++;
}
else {
$colSpan=0;
$itemColCount = 4;
$itemIndex = 0;
}
while ($itemColCount > 0)
{
if ($colSpan > 0)
{
print "<td colspan=\"$colSpan\">$itemCount".$row['name']."</td>"; // $row['itemName']
}
else
{
print "<td>item$itemCount".$row['name']."</td>"; // $row['itemName']
}
$itemCount++;
$itemColCount--;
}
$itemColCount = 0;
$colSpan = 0;
print "\n";
</tr>
}
</table>
私が所望のプログラムの出力を達成するためにどのように助けを必要とします。これを達成するために必要なものはhttp://img828.imageshack.us/img828/4411/correctj.pngです。
申し訳ありませんが、私は間違った正しい画像に大きな違いはありません。あなたはとても親切で、正確に何を達成したいのか説明してください。 – Ranty