title: display mysql data on page without refreshing page - drop down list
body: <p>I need some help please,</p>
  
  <p>I have a PHP page with a drop down list, populated by a mysql database query.
  I want to be able to display the database details for the selected option in the other table cells.
  Ideally this can be acheived without a page refresh.</p>
  
  <p>In addition to this the table will consist of up to 75 rows (pallets on the vehicle - this is for a sales tool) so need to acheive this with a a while statement or something. each row will have a selection box to choose a packcode.</p>
  
  <p>my code with the drop down lists is below, the table only consists of the 5 rows for now. </p>
  
  <p>I know I need to use ajax or javascript in addition to this? </p>
  
  <p>If anyone has an example script or can use my code as an example I would really appreciated it.</p>
  
  <pre><code>&lt;?
  
    $con = mysql_connect("localhost","user","password");
    if (!$con)
    {
      die('Could not connect: ' . mysql_error());
    }
  
    mysql_select_db("dbname", $con);
  
    $packcodesql="SELECT packcode from skudata order by packcode"; 
    $resultpackcode=mysql_query($packcodesql); 
    $optionspackcode=""; 
  
    while ($row=mysql_fetch_array($resultpackcode)) { 
       $packcode=$row["packcode"]; 
       $optionspackcode.="&lt;OPTION VALUE=\"$packcode\"&gt;".$packcode; 
    } 
  ?&gt;
  
  &lt;table border=1&gt;
  &lt;tr&gt;
    &lt;td&gt;Pack Code&lt;/td&gt;
    &lt;td&gt;Category&lt;/td&gt;
    &lt;td&gt;Selling Units&lt;/td&gt;        
    &lt;td&gt;Full Pallet QTY&lt;/td&gt;
    &lt;td&gt;Order QTY&lt;/td&gt;
  &lt;/tr&gt;
  &lt;Tr&gt;
    &lt;td&gt;
      &lt;SELECT NAME=packcode1 style="width:100px;"&gt; 
          &lt;OPTION VALUE=0&gt;&lt;?=$optionspackcode?&gt;&lt;/SELECT&gt; 
    &lt;/td&gt;
    &lt;td&gt;
      &lt;!-- show mysql result for "select Category from skudata where packcode=packcode1" --&gt;
    &lt;/td&gt;
    &lt;td&gt;
      &lt;!-- show mysql result for "select SellingUnits from skudata where packcode=packcode1" --&gt;
    &lt;/td&gt;     
    &lt;td&gt;
      &lt;!-- show mysql result for "select FullPalletQTY from skudata where packcode=packcode1" --&gt;
    &lt;/td&gt;
    &lt;td&gt;&lt;input type="text" id="qty" name="qty"&gt;&lt;/td&gt;
  &lt;/tr&gt;       
  &lt;Tr&gt;
    &lt;td&gt;
      &lt;SELECT NAME=packcode2 style="width:100px;"&gt; 
          &lt;OPTION VALUE=0&gt;&lt;?=$optionspackcode?&gt;&lt;/SELECT&gt; 
    &lt;/td&gt;
    &lt;td&gt;
      &lt;!-- show mysql result for "select Category from skudata where packcode=packcode2" --&gt;
    &lt;/td&gt;
    &lt;td&gt;
     &lt;!-- show mysql result for "select SellingUnits from skudata where packcode=packcode2" --&gt;
    &lt;/td&gt;     
    &lt;td&gt;
     &lt;!-- show mysql result for "select FullPalletQTY from skudata where packcode=packcode2" --&gt;
    &lt;/td&gt;
    &lt;td&gt;&lt;input type="text" id="qty" name="qty"&gt;&lt;/td&gt;
  &lt;/tr&gt;       
  &lt;Tr&gt;
     &lt;td&gt;
      &lt;SELECT NAME=packcode3 style="width:100px;"&gt; 
          &lt;OPTION VALUE=0&gt;&lt;?=$optionspackcode?&gt;&lt;/SELECT&gt; 
     &lt;/td&gt;
     &lt;td&gt;
      &lt;!-- show mysql result for "select Category from skudata where packcode=packcode3" --&gt;
     &lt;/td&gt;
     &lt;td&gt;
      &lt;!-- show mysql result for "select SellingUnits from skudata where packcode=packcode3" --&gt;
     &lt;/td&gt;        
     &lt;td&gt;
      &lt;!-- show mysql result for "select FullPalletQTY from skudata where packcode=packcode3" --&gt;
     &lt;/td&gt;
     &lt;td&gt;&lt;input type="text" id="qty" name="qty"&gt;&lt;/td&gt;
  &lt;/tr&gt;       
  &lt;Tr&gt;
     &lt;td&gt;
      &lt;SELECT NAME=packcode4 style="width:100px;"&gt; 
          &lt;OPTION VALUE=0&gt;&lt;?=$optionspackcode?&gt;&lt;/SELECT&gt; 
     &lt;/td&gt;
     &lt;td&gt;
      &lt;!-- show mysql result for "select Category from skudata where packcode=packcode4" --&gt;
     &lt;/td&gt;
     &lt;td&gt;
     &lt;!-- show mysql result for "select SellingUnits from skudata where packcode=packcode4" --&gt;
     &lt;/td&gt;        
     &lt;td&gt;
      &lt;!-- show mysql result for "select FullPalletQTY from skudata where packcode=packcode4" --&gt;
     &lt;/td&gt;
     &lt;td&gt;&lt;input type="text" id="qty" name="qty"&gt;&lt;/td&gt;
  &lt;/tr&gt;       
  &lt;/table&gt;
  </code></pre>