title: How to extract/split part of the data AJAX Success returning
body: <p>I have this PHP code to select data from a database:</p>
  
  <pre><code>&lt;?php
  include './database_connect.php';
  
  $ppid=$_POST['selectPatientID'];
  
  $query="SELECT * FROM patient WHERE p_Id='$ppid'";
  
  $result=  mysqli_query($conn, $query);
  while($row=  mysqli_fetch_array($result)){
      echo ($row['p_fname']); 
      echo ' ';
      echo ($row['p_lname']);
  }    
  ?&gt;  
  </code></pre>
  
  <p>But I need to get the <code>p_fname</code> and <code>p_lname</code> values separately. Is there anything I could do to achieve this?</p>
  
  <p>This is my jQuery:</p>
  
  <pre><code>    &lt;script&gt;
                  $(document).ready(function () {
                      $('#selectPatientID').on('change', function (event) {
                          event.preventDefault();
  //                        alert("Hi");
                          $.ajax({
                              url: "UDPatient.php",
                              type: 'POST',
                              data: {selectPatientID: $('#selectPatientID').val()},
                              dataType: 'html',
                              success: function (result) {
                                  $('#patientName').val(result); //in here, how can I get the p_fname and p_lname separetely and put them in two different input fields?
                              }
                          });
                      });
                  });
              &lt;/script&gt;
  </code></pre>