title: Creating a dynamic table using php based on users input data
body: <p>Currently I am trying to create a daily class routine using PHP. Firstly the site will have seven days name as check box and a text box where users could enter number of class period.   </p>
  
  <p>When user will submit the form the code will create another form inside another table (looks like <a href="http://s10.postimg.org/5voakdu89/stack_php.jpg" rel="nofollow">this</a>). And finally user could enter class name, teacher name and the code will store it in database. </p>
  
  <p><strong>But my problem is creating the table dynamically. I can not finding out how to solve this problem.</strong> </p>
  
  <p>Any help would be appreciated.</p>
  
  <p>Below you can see what I have tried so far:</p>
  
  <pre><code>&lt;h1&gt;Form two&lt;/h1&gt;
  
  &lt;form action="routine_create_process.php" method="POST"&gt;
  &lt;h3&gt;How many class period do you want to add?&lt;/h3&gt;
  
  &lt;input type="text" name="period"/&gt;
  
  &lt;h3&gt;Avalible class day&lt;/h3&gt;
  
  &lt;label&gt;&lt;input type="checkbox" name="f[]" value="sat" /&gt; Saturday &lt;/label&gt;
  &lt;br /&gt;
  &lt;label&gt;&lt;input type="checkbox" name="f[]" value="sun"  /&gt; Sunday &lt;/label&gt;
  &lt;br /&gt;
  &lt;label&gt;&lt;input type="checkbox" name="f[]"  value="mon" /&gt; Monday &lt;/label&gt;
  &lt;br /&gt;
  &lt;label&gt;&lt;input type="checkbox" name="f[]"  value="tues" /&gt; Tuesday &lt;/label&gt;
  &lt;br /&gt;
  &lt;label&gt;&lt;input type="checkbox" name="f[]"  value="thurs" /&gt; Wednesday &lt;/label&gt;
  &lt;br /&gt;
  &lt;label&gt;&lt;input type="checkbox" name="f[]"  value="thus" /&gt; Thursday &lt;/label&gt;
  &lt;br /&gt;
  &lt;label&gt;&lt;input type="checkbox" name="f[]"  value="fri" /&gt; Friday &lt;/label&gt;
  &lt;br /&gt;
  &lt;input type="submit" value="SUBMIT"/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>My PHP code:</p>
  
  <pre><code>&lt;?php
  $period=$_POST['period'];
  $arr2=$_POST['f'];
  ?&gt;
  
  &lt;table border='2'&gt;
  &lt;?php 
  $count=count($arr2)-1;
  for($i=0;$i&lt;=$count;$i++){
    echo "&lt;tr&gt;&lt;td&gt;";
    if($i==0){
      echo "&lt;table&gt;";
      echo "&lt;div class='wrap_p'&gt;";
      for($r=1;$r&lt;=$period;$r++){
        echo "&lt;td&gt;";
        echo "&lt;div class='add_css'&gt;";
        echo $r;
        echo "&lt;/div&gt;&lt;/td&gt;";
      }
      echo "&lt;/div&gt;";
      echo "&lt;/table&gt;";
    }
    echo "&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;"; 
    echo $arr2[$i];
    echo "&lt;/td&gt;";
    echo "&lt;td&gt; &lt;input type='text' size='20' /&gt;&lt;/tr&gt;&lt;/td&gt;";
  }
  ?&gt;
  &lt;/table&gt;
  </code></pre>