jQuery code causing conflict in results
<p>I would like to ask, is there a better way to run this code. I have a form with a select of #BA_customer which when selected populates a second menu with the address of the selected client. I also need to display a dept dropdown based on the customer selecetion. I think the code I have is causing a conflict where the customer is being passed twice in  2 seperate statements. What is the correct way to do this? Many thanks</p>

<pre><code>    &lt;script language="javascript" type="text/javascript"&gt;
          $(function() {
                $("#BA_customer").live('change', function() { if ($(this).val()!="")
                $.get("../../getOptions.php?BA_customer=" + $(this).val(), function(data) {
                $("#BA_address").html(data); });
            }); 
          });
    &lt;/script&gt;
    &lt;script language="javascript" type="text/javascript"&gt;
          $(function() {
                $("#BA_customer").live('change', function() { if ($(this).val()!="")
                $.get("../../getDept.php?BA_customer=" + $(this).val(), function(data) {
                $("#BA_dept").html(data); });
            }); 
          });
    &lt;/script&gt;
</code></pre>

<p>+++++++ dept.php Code +++++++++++++++++++++</p>

<pre><code>$customer = mysql_real_escape_string( $_GET["BA_customer"] ); // not used here, it's the customer choosen

    $con = mysql_connect("localhost","root","");
    $db = "sample";
      if (!$con)
        {
        die('Could not connect: ' . mysql_error());
        }

        mysql_select_db($db, $con);
        $query_rs_select_dept = sprintf("SELECT * FROM departments where code = '$customer'");
        $rs_select_dept = mysql_query($query_rs_select_dept, $con) or die(mysql_error());
        $row_rs_select_dept = mysql_fetch_assoc($rs_select_dept);
        $totalRows_rs_select_dept = mysql_num_rows($rs_select_dept);



          echo '&lt;label for="dept"&gt;Select a Department&lt;/label&gt;'.'&lt;select name="customerdept"&gt;';
          echo '&lt;option value=""&gt;Select a Department&lt;/option&gt;';
          while ($row_rs_select_dept = mysql_fetch_assoc($rs_select_dept))
          {
          $dept=$row_rs_select_dept['name'];
          echo '&lt;option value="dept"&gt;'.$dept.'&lt;/option&gt;';
          }
          echo '&lt;/select&gt;';
</code></pre>

<p>++++ SOLUTION +++++++++++++</p>

<pre><code>mysql_select_db($db, $con);
$query_rs_dept = sprintf("SELECT * FROM departments where code = '$customer'");
$rs_dept = mysql_query($query_rs_dept, $con) or die(mysql_error());
$totalRows_rs_dept = mysql_num_rows($rs_dept);

echo '&lt;label for="dept"&gt;Select a Department&lt;/label&gt;'.'&lt;select name="customerdept"&gt;';
echo '&lt;option value=""&gt;Select a Department&lt;/option&gt;';
while ($row_rs_dept = mysql_fetch_assoc($rs_dept))
{
       $dept=$row_rs_dept['name'];
       echo '&lt;option value="dept"&gt;'.$dept.'&lt;/option&gt;';
}
echo '&lt;/select&gt;';
</code></pre>

<p>Remove the first $row_rs_select_dept = mysql_fetch_assoc($rs_select_dept); from the script and it works. Just posted solution in case some other soul needs help with  problem like this.</p>
