Php looping table columns and rows
Php looping table columns and rows

Shopinson codes today again is on ‘PHP looping table columns and rows

This code is a long SEARCH on google as far I can know and REASONS because so many developers both beginners and the professional might want to create something alike that will automatically create a table and the row or column based on the intellectual need of either developers.

See also : Python listing files contained a defined directory

For example : below is a code (PHP) that will create 7 by 3 table automatically

<?php //Refresh it everytime.  $row = 7; //The Needed numbers of Row  $col = 3; // The Needed numbers of Column  $numbering= 1; // This will php-loop-creates-table-rows-columns/">loop the numbers contained in each cell using $numbering++ (auto increment php/php-mail-function-image-documents-attachment/">functionphp-php-loop-creates-table-rows-columns/">loop-creates-table-rows-columns/"> php php-loop-creates-table-rows-columns/">loop)  echo '<table border="1">';  for($i=1;$i<=$row;$i++){ echo '<tr>';    for($j=1;$j<=$col;$j++){ echo '<td>'. $numbering++ .'</td>'; }    echo '</tr>';  }  echo '</table>';  ?>
Result: PHP codes above created 7rows and 3 columns as shown in the result here below

In the above code just by manipulating (changing) the number values in the either of the variables $row or $col for the table column or row then the table will be altered automatically and respectively and you will have the actually number values of columns or rows you input right your desired table for any of your desired purpose.

see also:

Now notice that the PHP variable $numbering loops numbering continuously across the cells in the table without that variable that loops continuous numbering across the cell the code will misbehave

The variable $row represent the row of the table while the $col represent the column

Basically the row or a column of a table in Php are LOOPED predominantly using command.

see also:


Please enter your comment!
Please enter your name here