Dynamic table generator

Discussion in 'PHP' started by vetrivel, Dec 27, 2010.

  1. #1
    Hi ,
    I would like to generate the table dynamically by providing no. of rows and columns and also I need to enter the value for each cell .
    then when i click the generate button ,the system need to provide me the code for the above created table.
    EX: http://tablegen.nfshost.com/index.py
    But it is done it python ,i need it in php or ajax or javascript but similar to this .

    How to do any idea .
    Any predefined one?
     
    vetrivel, Dec 27, 2010 IP
  2. pig2cat

    pig2cat Active Member

    Messages:
    299
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    60
    #2
    very easy;

    
    $rows = 10;
    $collums = 20;
    $counter = 0;
    
    echo '<form method=POST><table border=1>';
    for($i = 0; $i < $rows; $i++)
    {
    echo '<tr>';
    
    for($ii = 0; $ii < $collums; $ii++)
    {
    echo '<td><textarea name="box' . $counter . '"></textarea></td>';
    $counter++;
    }
    
    echo '</tr>';
    }
    echo '</table></form>';
    
    
    PHP:
    you can then pretty much copy this again but instead of the textarea just echo $_POST['box' . $counter]
    or
    <textarea name="box' . $counter . '">'. $_POST[box' . $counter . '] . '</textarea>


    i've written this in this post, so it might not work without some debugging.
     
    Last edited: Dec 27, 2010
    pig2cat, Dec 27, 2010 IP
  3. vetrivel

    vetrivel Peon

    Messages:
    147
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi ,
    I was just blank out on that day .
    Now i got it ,I will post it completely soon.
     
    vetrivel, Dec 28, 2010 IP