title: How can I retrieve multiple data from MYSQL using PHP and Javascript?
body: <p>I have this code below that retrieves data from the database when the user inputs the PRD number and hits the "enter" key. It works fine for displaying single data but I need to display multiple data(PRDNO, PRDITEMCODE, PRDQTY).</p>
  
  <p>Js code:</p>
  
  <pre><code>$("#prNum").keypress(function(e){
      if(e.keyCode==13){
          var getPR = $("#prNum").val(); //gets the value entered on supCode textbox
  
          if($.trim(getPR) != ""){
              $.post("ajax/prdetails.php", {getPR: getPR}, function(data){
                  if(data == "error"){
                      alert("Purchase Request number not found.");
                      $("#prNum").text("");
                  }       
                  else
                  {
                      $("#displayPRD").text(data);
                  }
  
              });
  
          }
  
      }    
  
  }); //end prNum keypress
  </code></pre>
  
  <p>Php code:</p>
  
  <pre><code>if(isset($_POST['getPR']) === true &amp;&amp; empty($_POST['getPR']) === false)
   {
      mysql_connect('localhost', 'root', '') or die("Could not connect to server.");
      mysql_select_db('cch');
  
      $query = mysql_query("
          SELECT `PRDNO` , `PRDITEMCODE` , `PRDQTY`
          FROM `prdetailfile`
          WHERE `PRDNO` = '" . mysql_real_escape_string(trim($_POST['getPR'])) . "' 
      ");
      if (!$query) 
      {
          die(mysql_error());
      }
  
      echo (mysql_num_rows($query) !== 0) ? mysql_result($query, 0, 'PRDNO') : 'error';
  
   }
  </code></pre>
  
  <p>I can't seem to find a way to store each column value in an array.
  Btw, I need to display the data by rows in an existing table in HTML and should look like this:</p>
  
  <h2>PRDNO   |   PRDITEMCODE   |   PRDQTY</h2>
  
  <h2>PR001   |    IC001        |     50</h2>
  
  <h2>PR001   |    IC002        |     40</h2>
  
  <p>PR001   |    IC003        |     30</p>
  
  <p>The Purchase Reuquest(PRDNO) can have multiple item orders(PRDITEMCODE) with corresponding quantity. I would greatly appreciate if someone can help me with this. THANKS!</p>
  
  <p>EDIT: Sorry for the poor representation of a table. I can't post an image yet but that's how the table should look like :)</p>