PHP looping table columns and rows

PHP looping table columns and rows

0
1124
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 for PHP looping table columns and rows have been a long SEARCH on google as far I can know.

REASONS because so many developers both beginners and the professional might want to create something alike that will automatically create a table and loop the row or column based on the intellectual need of either developers.

You can also checkout our newly created TableLooper() php class object that uses do while and for php loop statement to automatically insert user specified arrays of contents in the cells as the rows and column are being looped.

PHP looping table
PHP looping table

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 loop the numbers contained in each cell using $numbering++ (auto increment function php 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

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 for loop command.

see also:

Running metasploit framework on windows OS

LEAVE A REPLY

Please enter your comment!
Please enter your name here