title: PHP or Jquery to populate form fields?
body: <p>As I am new to this I would like your advice.<br>
  So far I have figured out two ways to populate form fields.<br>
  Say this is my html:  </p>
  
  <pre><code> &lt;input id="test" name="test" type="text"&gt;  
  </code></pre>
  
  <p>As you see the id of each field matches the name.<br>
  When it's time to populate the field from Sql i could either do:</p>
  
  <p>PHP:</p>
  
  <pre><code> &lt;input id="test" name="test" type="text" value="&lt;?php if(isset($SqlRequested['test'){echo $SqlRequested['test'];}"&gt;  
  </code></pre>
  
  <p>and similarily write all the fields of my form...<br>
  or add this in the head part<br>
  JQUERY:</p>
  
  <pre><code>&lt;script&gt;
   &lt;?php  echo "$(document).ready(function(){";
          foreach ($SqlRequested as $id =&gt; $value){
                  echo "$('#" . $id . "').val(\"" . $value . "\");"
                  echo "};"
           echo "});"
   ?&gt;
   &lt;/script&gt;
  </code></pre>
  
  <p>besides the fact that the jQuery gives me some problems when the fields contain "enter/return" in them (which could be fixed by using .html or .text i guess)</p>
  
  <p>Which one would you suggest, what are the drawbacks or pro's of each method?<br>
  Any improovements to the code?<br>
  Is there some other way i am missing?<br>
  Any suggestions on easily fixing the little problem mentioned above?</p>
  
  <p>Thanx in advance.</p>
  
  <p>Edit: I just noticed the jQuery .populate, which im guessing is something like my second way, you just need to get your data in a format of <code>{'id':'value',...}</code></p>