title: Dynamically adding fields to Form with DB values, php
body: <p>Alright so, I have a form consisted of a number of elements and I want the user to be able to dynamically add contents to the form (ideally without the use of JS to not reveal SQL queries and stuff). At the moment I'm trying to do that in php and a sample of the code is as below:</p>
  
  <p>Let's assume that there is a form and a table, t1, in it. I want the user to be able to add
  ,by pressing a button or w/e, an identical table, t2 up to a set tn, to the form, with changed ids (which is simple).<br>
  To what extent is this possible w/o revealing SQL stuff and w/o the need to reload the page?</p>
  
  <pre><code>&lt;form ...&gt;
  ...
  
  echo'&lt;table id="t1" ...&gt;
   &lt;tr&gt;
     &lt;td&gt;Text&lt;/td&gt;
     &lt;td&gt;Text&lt;/td&gt;
     &lt;td&gt;Text&lt;/td&gt;
     &lt;td&gt;Text&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;';
       $query = "SELECT * FROM randomTable";
       $exec = mysql_query($query ) or die(mysql_error());
  
       $num = 0;
       while ($row= mysql_fetch_array($exec))
       {
         if ($num == 0)
         {
           echo '&lt;select id="t1_show"&gt;
                 &lt;option value="" selected="selected"&gt;
                 &lt;option value="' . $row['id'] . '"&gt;'
                 . $row['name'] . '&lt;/option&gt;';
           $num ++;
         }
         else
         {
           echo '&lt;option value="' . $row['id'] . '"&gt;'
                 . $row['name'] . '&lt;/option&gt;';
           $num ++;
         }
       }
       if ($num &gt; 0) echo '&lt;/select&gt;';
  
       echo '&lt;/td&gt;
             &lt;td&gt;&lt;input id="t1_input1" type="text"/&gt;&lt;/td&gt;
             &lt;td&gt;&lt;input id="t1_input2" type="text"/&gt;&lt;/td&gt;
             &lt;td&gt;&lt;input id="t1_input3" type="text"/&gt;&lt;/td&gt;
           &lt;/tr&gt;
  
    &lt;/table&gt;';
  
  ...
  </code></pre>
  
  <p></p>