title: Get patient details on combo box change
body: <p>I need the code for getting the addr and pnum of the patient when I choose the pname in the combo box.</p>
  
  <p>How can I do that?  </p>
  
  <pre><code>&lt;script&gt;
  
  function getVal() {
  document.getElementById("text2").value = document.getElementById("model").value;
  }
  &lt;/script&gt;   
  
  &lt;body&gt;
  //code in opening and getting my addr and pnum in dbase
  
  &lt;?php
  include('connect.php');
  $pname=$_GET['tpname'];
  $result = mysql_query("SELECT * FROM tblnpatient where pname='$pname'");
  
  while($row = mysql_fetch_array($result))
      {
          $pnum=$row['pnum'];
          $addr=$row['addr']; 
  }
  ?&gt;
  
  //code for choosing pname
  
  &lt;tr&gt;&lt;td&gt;Patient Name:
  &lt;div id="ma"&gt;
  &lt;select name="pname" class="textfields" id="model"  style="width:180px;"      onchange="getVal();"&gt;
  &lt;option id="0" &gt;--Select Patient Name--&lt;/option&gt;
   &lt;?php
      $con=mysqli_connect("localhost","root","","dbnpatient");
          if (mysqli_connect_errno()){
            echo "Failed to connect to MySQL: " . mysqli_connect_error();
          }
      $pnum=$_GET['pnum'];
      $query = mysqli_query($con, "SELECT * FROM tblnpatient");
      while($row = mysqli_fetch_array($query)){
          $pnum = $row['pnum'];
          $pname = $row['pname'];
   ?&gt;
   &lt;option id="&lt;?php echo $pnum; ?&gt;" value="&lt;?php echo $pname; ?&gt;"&gt;&lt;?php echo $pname; ?&gt;  &lt;/option&gt;
   &lt;?php } ?&gt;
  &lt;/select&gt;
  
  //code for getting pname and addr
  
  Address:&lt;input type="text" name="ename" size="20"  id="ma" value="&lt;?php echo $addr ?&gt;"/&gt;
  Name:&lt;input type="text" name="ename" size="20"  id="ma" value="&lt;?php echo $pname ?&gt;"/&gt;
  </code></pre>
  
  <p></p>