If I want a <tr> to appear every 22 <td>s, including the 0 at, the beginning how is the if statement written?
When the td counter is a multiple of 22 you could close of the tr (but not if its the first one) and start a new one (unless it’s the last one).
You can use $i % 22 === 0 to check that it’s a multiple of 22, and the rest of basic if statements within the loop.
An alternative way is to step by 22 on the outer loop, where you create the tr, and use an inner loop to create the td’s
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<style type="text/css">
td {
border: 1px solid rgb(0,0,128)
}
</style>
</head>
<body>
<table>
<?php
$numRows = 2;
$numTdPerRow = 12;
for ($i = 1; $i <= $numRows; $i++) {
echo '<tr>';
for ($j = 1; $j <= $numTdPerRow; $j++) {
echo '<td>tr = ' . $i . ' td = ' . $j . '</td>';
}
echo '</tr>';
}
?>
</table>
</body>
</html>
Isn’t this going to render:
tr = ’ . $i . ’ td = ’ . $j . ’
in each td tag?
What did it render when you ran it?
Since you put your op in the php thread I assume you have access to run php scripts.