how to fetch multiple tables value of database into dynamic select box
<p>here i'm trying to fetch data into combobox from database in which i have 10 table. i have two combo box, in first box i called option from database which will be the first table and the option like a, b, c, d. Now when i'm selecting 'a' in first box then it should called the corresponding value through php and that value will be come from another table and there is nothing common key in both of them tables.
Same as when selecting 'b' then it will call the another value from the 3rd table.</p>

<p>So here i was trying with the if else condition but i'm able get output .
somebody please improve jquery mistake , in which way i should match the condition of it .</p>

<p>here's my code html page</p>

<pre><code>    &lt;html&gt;
    &lt;body&gt;
    &lt;select id="a1_title"&gt;
    &lt;/select&gt;
    &lt;select id="a2_title"&gt;
    &lt;/select&gt; 
    &lt;script src="jquery-2.0.3.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript"&gt;
    $(document).ready(function(){
      $.getJSON("drpdwn.php", success = function(data){
    var items="";
        for(var i = 0; i&lt; data.length; i++){
           items +="&lt;option value='"+ data[i].toLowerCase() +"'&gt;" + data[i] +"&lt;/option&gt;";
        }
        $("#a1_title").append(items); 
        $("#a1_title").change();
      });
   $("#a1_title").change(function(){
    if( data.length == 1) // here i have tried to match the condition from ID but it doesn't work 
{
    alert("b");
      $.getJSON("lulc_db.php",success = function(data){
    alert("okay");
       var items="";
       for(var i = 0; i&lt; data.length; i++){
          items+="&lt;option value='"+data[i].toLowerCase()+"'&gt;"+data[i]+"&lt;/option&gt;";
       }
 else   if( data.length == 2) 
{
    alert("b");
      $.getJSON("soil_db.php",success = function(data){
    alert("okay");
       var items="";
       for(var i = 0; i&lt; data.length; i++){
          items+="&lt;option value='"+data[i].toLowerCase()+"'&gt;"+data[i]+"&lt;/option&gt;";
       }
        $("#a2_title").append(items); 

      });
     }
    });

});
 &lt;/script&gt;
 &lt;/body&gt;&lt;/html&gt;
</code></pre>

<p>This is drpdown.php page .This page value will successfully coming in first select box.</p>

<pre><code>&lt;?php
$host = "localhost"; 
$user = "postgres"; 
$pass = "admin"; 
$db = "Querybuilderdb"; 

$con = pg_connect("host=$host dbname=$db user=$user password=$pass")
    or die ("Could not connect to server\n"); 
$query = "SELECT id, name FROM tab";
$result = pg_query($con, $query);
if(pg_num_rows($result)){

$data=array();
while($row=pg_fetch_array($result))
{ array_push($data, $row["name"]);

}

echo  json_encode($data);
}
?&gt;
</code></pre>

<p>Here the lulc_db.php .This page value should come in second select box.Same like this i have 8 other php page ,which i have show into second combobox.</p>

<pre><code>    &lt;?php 
require "config.php";
$query = "SELECT distinct level_1 FROM pachgaon_LULC";
$result = pg_query($con, $query);
if(pg_num_rows($result)){
$data=array();
while($row=pg_fetch_array($result))
{ array_push($data, $row["level_1"]);
}
echo  json_encode($data);
}
?&gt;
</code></pre>

<p>Thanks in advanced :)</p>