Table, TR each 2 loop, PHP, HTML again
I've has help with the problem: Table, TR each 2 loop, PHP, HTML
But it still doesn't work, so I post my loop structure, because if I add:
if($i % 2 == 0) {
echo '</tr><tr bgcolor="#4B4B4B">';
}
It doesn't even close & re open the table row (tr).
Here is my loop structure:
$similar .= '<table width="100%" bgcolor="#000" class="tbContent" border="0" cellspacing="1" cellpadding="4">';
$similar .= '<tr bgcolor="#4B4B4B">';
while ($row = $db->fetch_array($query)) {
$similar .= '
<td>
<table width="100%">
<tr>
<td></td>
<td>Pojedynek #' . $i . ':</td开发者_运维知识库>
<td></td>
</tr>
<tr>
<td>
<h1><a href="/' . $row["id"] . '/' . $row["link"] . '">' . $wT . '</a></h1>
</td>
<td></td>
<td>
<h1><a href="/' . $row["id"] . '/' . $row["link"] . '">' . $oT . '</a></h1>
</td>
</tr>
<tr>
' . $wContent . '
<td width="10%"><h2>przeciwko</h2></td>
' . $oContent . '
</tr>
</table>
</td>
';
if($i % 2 == 0) {
echo '</tr><tr bgcolor="#4B4B4B">';
}
$i++;
}
$similar .= '</tr></table>';
You need to put $i = 0
outside the loop, not initialising it means it will be initialised with zero every time your loop goes round and your if statement will either always fire or never fire
精彩评论