I have some code that shows results in a table
Right now it will show 3 cells per row. The issue is that the first row shows 2 then creates a new row with the expected behavior fine after that. How can I get the first row to show 3 cells
if(++$cnt == 0) {
echo '<tr>';
} elseif($cnt % 3 == 0) {
echo '</tr><tr>';
}
echo "<td bgcolor='#009933'><a href='" . $row['local_link'] . ".m4v' name='video'>" . $row['local_link'] . "</a></td>";
echo "<td><video width='320' height='240' controls='controls'>
<source src='" . $row['local_link'] . ".m4v" . "' type='video/mp4' />
Your browser does not support the video tag.
</video></td>";
}
}
echo "</table>";
You’re preincrementing
$cnton your first line, meaning it will never be zero – unless you started it at-1. Try changing your first line to:This way the value of
$cntis incremented after you compare it to zero, not before.