title: Php: How to get textbox value from mysql database without submitting the form
body: <p>I want to check the values from either one of the two textboxes text boxes that matches the value with the other without submitting the form. The keypress event is handling this, sending the value from jour_info.php page to get_sid.php page.
  I have two files</p>
  
  <ol>
  <li>jour_info.php</li>
  <li>get_sid.php</li>
  </ol>
  
  <p>The code in the first file</p>
  
  <pre><code>&lt;form method="post" name="journ_form" &gt;
  P-ISSN/ISBN&lt;br/&gt;&lt;input name="printissn" id="printissn_input" type="text" value=""&gt;
                                              &lt;input type="text" name="pissnsid" id="pissnsid" style="width: 30px;" autocomplete="off" value=""&gt;
  
                                              &lt;span style="color: red;" id="feedback"&gt;&lt;/span&gt;
   &lt;/form&gt;
  
  &lt;script type="text/javascript"&gt;
   $(document).ready(function(){
  $('#feedback').load('get_sid.php').show();
  
  $('#printissn_input').keyup(function(){
  
      $.post('get_sid.php', {printissn: journ_form.printissn.value},
      function(result) {
          //$('#feedback').html(result).show();
          document.getElementById('pissnsid').value = result;
      }); 
  });
  
  
  $('#pissnsid').keyup(function(){
      $.post('get_sid.php', {pissnsid: journ_form.pissnsid.value},
      function(result) {
          document.getElementById('printissn_input').value = result;
      });
  });
  });
  </code></pre>
  
  <p></p>
  
  <p>The code in the second file</p>
  
  <pre><code>&lt;?php
   include 'auth.php';
  
   $printissn = $_POST['printissn'];
   $pissnsid = $_POST['pissnsid'];
  
   if($printissn){
  $check = mysql_query("SELECT printissn, pissnsid FROM jour_entries WHERE   printissn='$printissn'");
  $check_num_rows = mysql_num_rows($check);
  while($row = mysql_fetch_array($check)){
      //$get_printissn = $row['printissn'];
      $get_printissnsid = $row['pissnsid'];
      if($check_num_rows == 0){
          echo '';
      } else if($check_num_rows == 1){
          echo $get_printissnsid; 
      }
  }
    } else if($pissnsid){
    $check = mysql_query("SELECT printissn, pissnsid FROM jour_entries WHERE pissnsid='$pissnsid'");
    $check_num_rows = mysql_num_rows($check);
    while($row = mysql_fetch_array($check)){
  $get_printissn = $row['printissn'];
  //$get_printissnsid = $row['pissnsid'];
  if($check_num_rows == 0){
      echo '';
  } else if($check_num_rows == 1){
      echo $get_printissn;    
  } 
   }
  } 
  ?&gt;
  </code></pre>
  
  <p>Now everything is working fine, the problem is when a value is entered in the first text box its showing the corresponding match in the second text box. But in case if the value doesn't match with the two fields and user needs to enter manually the data, the problem arises. When there is no match and user enters a value in first textbox, then the second textbox value disappears. How to solve that?</p>