Creating Dynamic HTML tables with PHP Script

    <?php
    function create_html_rows_column_table($no_of_rows,$no_of_columns)
    {
     $html = "<table>";
     for ($row_counter=0;$row_counter<$no_of_rows;$row_counter++)
      {
       $html .= "<tr id='row_".$row_counter."'>";
       for ($col_counter=0;$col_counter<$no_of_columns;$col_counter++)
          {
        $html .= "<td id='col_".$col_counter."'>";
        $html .= "<input type='text' name='input_".$row_counter.$col_counter."' id='input_".$row_counter.$col_counter."' value=''>";
        $html .= "</td>";
       }
       $html .= "</tr>";
      }
      $html .= "</table>";
      return $html;
      }
     //create table of input boxes of 4 rows and 4 columns
     echo create_html_rows_column_table(4,4);
     exit;
    ?>

0 comments:

Post a Comment