title: How to write PHP code inside jquery for retrieving values from mysql database?
body: <p>I am trying to get the values for the next drop-down from a database, which will be dependent on two previous drop-downs. The values for first two drop-downs are listed in the file itself. I want the second drop-down to be enable after selecting values from first, and similarly for third after second. Kindly help. 
  HTML code below:</p>
  
  <pre><code>&lt;form&gt;
  &lt;select id="branch" name="branch" class="form-control" onchange="showUser(this.value)"&gt;
          &lt;option value=""&gt;Select&lt;/option&gt;
          &lt;option value="1"&gt;Civil&lt;/option&gt;
          &lt;option value="2"&gt;Computer&lt;/option&gt;
          &lt;option value="3"&gt;Mechanical&lt;/option&gt;
          &lt;option value="4"&gt;Electronics and Telecommunications&lt;/option&gt;
          &lt;option value="5"&gt;Electrical and Electronics&lt;/option&gt;
          &lt;option value="6"&gt;Information Technology&lt;/option&gt;
  &lt;/select&gt;
  &lt;select id="semester" name="semester" class="form-control" disabled&gt;
        &lt;option value="1"&gt;I&lt;/option&gt;
        &lt;option value="2"&gt;II&lt;/option&gt;
        &lt;option value="3"&gt;III&lt;/option&gt;
        &lt;option value="4"&gt;IV&lt;/option&gt;
        &lt;option value="5"&gt;V&lt;/option&gt;
        &lt;option value="6"&gt;VI&lt;/option&gt;
        &lt;option value="7"&gt;VII&lt;/option&gt;
        &lt;option value="8"&gt;VII&lt;/option&gt;
  &lt;/select&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>jquery is:</p>
  
  <pre><code>&lt;script&gt;
  
       $(document).ready(function(){
        document.cookie = "s =hello" ;
  
       console.log('hello');
  
           $("#semester").attr("disabled", true);
           $("#branch").change(function(){
               $("#semester").attr("disabled", false); 
  
                $b = $('#branch').val();
  
  
                $("#semester").change(function(){
                  $s = $('#semester').val();
                  $("#sub_code").attr("disabled", false);
                  console.log($s);
  
                  if($s!=1||$s!=2)
                  $s = $b+$s;
  
                  &lt;?php 
  
                   $s= $_COOKIE['s'];
  
                   $sql = "SELECT * FROM subjects WHERE sem_code=`$s`";
  
                  ?&gt;
  
               });   
           });
       });
       &lt;/script&gt;
  </code></pre>
  
  <p>I did not run the query since it is not assigned properly yet. </p>