html - Make Looping Table PHP -
i want make looping table in project.
here code:
<!doctype html> <html> <body> <table align="left" border="1" cellpadding="3" cellspacing="0"> <?php for($i=1;$i<=6;$i++) { echo "<tr>"; ($j=1;$j<=5;$j++) { echo "<td>$i"</td>"; } echo "</tr>"; } ?> </table> </body> </html>
i want make looping table auto number in first column. response this:
can 1 tell me how can make in first column?
expected result:
then move $i
outside of inner loop , add empty table data. reduce inner loop iteration 1 count:
<!doctype html> <html> <body> <table align="left" border="1" cellpadding="3" cellspacing="0"> <?php for($i=1;$i<=6;$i++) { echo "<tr>"; echo "<td>$i</td>"; ($j=2;$j<=5;$j++) { echo "<td> </td>"; } echo "</tr>"; } ?> </table> </body> </html>
note: typo in question - echo "<td>$i"</td>";
echo "<td>$i</td>";
Comments
Post a Comment