johnseito Posted December 20, 2007 Share Posted December 20, 2007 Hello, I was wondering if someone could show me the PHP code for building a GRID with numbers in each column and rows as axis. thanks - Quote Link to comment https://forums.phpfreaks.com/topic/82423-php-grid-with-index/ Share on other sites More sharing options...
johnseito Posted December 20, 2007 Author Share Posted December 20, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/82423-php-grid-with-index/#findComment-419213 Share on other sites More sharing options...
markjoe Posted December 20, 2007 Share Posted December 20, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/82423-php-grid-with-index/#findComment-419219 Share on other sites More sharing options...
johnseito Posted December 21, 2007 Author Share Posted December 21, 2007 works great thanks- Quote Link to comment https://forums.phpfreaks.com/topic/82423-php-grid-with-index/#findComment-420022 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.