php - How to create multiple textboxes as a table inside for loop -


this code

for($tr=1;$tr<=$rows;$tr++) {  echo "<tr>"; if($sec == 's+') {      for($td=1;$td<=$cols;$td++)     {          for($td=1;$td<=1;$td++)         {             echo "<td><input type='text' name='bhk' disabled value='$tr'></td>";          }         for($td=2;$td<=$cols;$td++)         {             echo "<td><input type='text' name='bhk'></td>";          }       } } else {     for($td=1;$td<=1;$td++)     {          echo "<td><input type='text' name='bhk' value='$tr' readonly></td>";      }     for($td=2;$td<=$cols;$td++)     {          echo "<td><input type='text' name='bhk'></td>";      } }  echo "</tr>"; 

}

this code there 1 textbox dynamically here. cover entire table, need add different textboxes different column.

your code working fine, i`m not sure having porblem if u can see structure generating:

$rows = 5; $sec = 's+'; $cols = 5;  for($tr=1;$tr<=$rows;$tr++) {   echo "<table style='border: 1px black solid'>";   echo "<tr>";     if($sec == 's+')     {        for($td=1;$td<=$cols;$td++)       {          for($td=1;$td<=1;$td++)          {     echo "<td><input type='text' name='bhk' disabled value='$tr'></td>";          }         for($td=2;$td<=$cols;$td++)         {             echo "<td><input type='text' name='bhk'></td>";           }          }    }    else    {       for($td=1;$td<=1;$td++)       {  echo "<td><input type='text' name='bhk' value='$tr' readonly></td>";       }     for($td=2;$td<=$cols;$td++)     {          echo "<td><input type='text' name='bhk'></td>";      } }  echo "</tr>"; echo "</table>"; } 

just modify inside of if`s generate structure u want.


Comments