Jump to content

PHP GRID with index


johnseito

Recommended Posts

for example:

 

I use double for loop to do this

 


for ($i = 0; $i < $height; $i++) {

    }
    for ($j = 0; $j < $width; $j++) {
     
    print "<font size =6.5>_</font>";
        print("<font size=5>|</font>");

}

 

the thing is that I can't get the number on the column and rows.

 

thanks

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/82423-php-grid-with-index/#findComment-419213
Share on other sites

Well, I think i get what your asking for.

 

<?php
$height=10;$width=10;
echo "<table border='1'><tr>";
for($i=0;$i<=$width;$i++){echo "<td>$i</td>";}
echo "</tr>";
for ($i = 1; $i <= $height; $i++) {
echo "<tr><td>$i</td>";
    for ($j = 1; $j <= $width; $j++) {
         echo "<td>x</td>";
}
echo "</tr>";
}
echo "</table>";
?>

 

Outputs:

 

0 1 2 3 4 5 6 7 8 9 10

1 x x x x x x x x x x

2 x x x x x x x x x x

3 x x x x x x x x x x

4 x x x x x x x x x x

5 x x x x x x x x x x

6 x x x x x x x x x x

7 x x x x x x x x x x

8 x x x x x x x x x x

9 x x x x x x x x x x

10 x x x x x x x x x x

Link to comment
https://forums.phpfreaks.com/topic/82423-php-grid-with-index/#findComment-419219
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.