title: Parsing JSON Data From MySQL Table to Different Divs
body: <p>Having a jQuery Ajax request from MySQL database I know how to render the data in an HTML element format like tables or list as below:</p>
  
  <pre><code>$.ajax({
                  type:"POST",
                  url:"appdata.php",
                  success: function (newdata) {
                      $('#result').html(newdata);
                  }
         });
  </code></pre>
  
  <p>The PHP as:</p>
  
  <pre><code>$mysqli = new mysqli('localhost', 'root', '******', '********');
  $resultStr = '';
  $query = 'SELECT * FROM appusers';
  if ($result = $mysqli-&gt;query($query)) {
   if ($result-&gt;num_rows &gt; 0) {
          $resultStr.='&lt;ul&gt;';
           while($row = $result-&gt;fetch_assoc()){
            $resultStr.= '&lt;li&gt;'.$row['fname'].' - '.$row['lname'].' - '.$row['phone'].'&lt;/li&gt;';
          }
           $resultStr.= '&lt;/ul&gt;';
          }
          else {
                 $resultStr = 'Nothing Found';
               }
      }
  echo $resultStr;
  ?&gt;
  </code></pre>
  
  <p>The other option, also, is passing the result as JSON by using the <code>json_encode()</code> as below</p>
  
  <pre><code>   $mysqli = new mysqli('localhost', 'root', '******', '********');
     $query = 'SELECT * FROM appusers';
     $result = $mysqli-&gt;query($query)-&gt;fetch_array();
     echo json_encode($result);
  </code></pre>
  
  <p>Now I am totally confused how to use this <code>json_encode($result)</code> in the Ajax call?
  For example can you please let me know if I want render the result of the query in series of divs like </p>
  
  <pre><code>&lt;div id"fname"&gt;&lt;/div&gt;
  &lt;div id"lname"&gt;&lt;/div&gt;
  &lt;div id"phone"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>how can I parse this in ajax success property? and associuate each field on related div?
  Thanks for you help in advanced.</p>
  
  <p>update:</p>
  
  <pre><code>var varfname;
  var varlname;
  var varphone;
  
  $(#fname).html(varfname);
  $(#lname).html(varlname);
  $(#phone).html(varphone);
  </code></pre>