How can i generate dynamic row in PHP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sriku
    New Member
    • Mar 2008
    • 6

    How can i generate dynamic row in PHP

    Hi Friends,

    i have page with few options. i need to generate multiple rows in page dynamically. in single row i have three labels and three select boxes,
    i need to get the number of row to be generated from user and need to generate those. Anyone can help in this issue?

    Thanks,
    Srikanth
  • myth0s
    New Member
    • Jan 2008
    • 32

    #2
    Originally posted by Sriku
    Hi Friends,

    i have page with few options. i need to generate multiple rows in page dynamically. in single row i have three labels and three select boxes,
    i need to get the number of row to be generated from user and need to generate those. Anyone can help in this issue?

    Thanks,
    Srikanth
    You can use a loop to create those rows.

    [PHP]$myTableRows;

    for($i = 0; $i<$nbOfRows; $i++) {
    $myTableRows .= '<tr><td><labe l for="1">L1</label><input id="1" type="checkbox" /></td><td><label for="2">L2</label><input id="2" type="checkbox" /></td><td><label for="3">L3</label><input id="3" type="checkbox" /></td></tr>';
    }

    // Further....

    echo '<table><thead> <th><td>Colum n 1</td><td>Column 2></td><td>Column 3</td></th></thead><tbody>'. $myTableRows.'</tbody></table>';
    [/PHP]

    Comment

    • Sriku
      New Member
      • Mar 2008
      • 6

      #3
      Originally posted by myth0s
      You can use a loop to create those rows.

      [PHP]$myTableRows;

      for($i = 0; $i<$nbOfRows; $i++) {
      $myTableRows .= '<tr><td><labe l for="1">L1</label><input id="1" type="checkbox" /></td><td><label for="2">L2</label><input id="2" type="checkbox" /></td><td><label for="3">L3</label><input id="3" type="checkbox" /></td></tr>';
      }

      // Further....

      echo '<table><thead> <th><td>Colum n 1</td><td>Column 2></td><td>Column 3</td></th></thead><tbody>'. $myTableRows.'</tbody></table>';
      [/PHP]
      Thanks Buddy.
      Srikanth

      Comment

      Working...