This is my display page

 <label for="City">City</label>
            <div id="city">
            <select id="city"  name="city" onChange="display(this.value)">
            <option value="" selected="selected">-- Select city --</option>
            <?php include("getcitylist.php");?>
            </select>
            </div>

this is my ajax page

    // JavaScript Document
var XMLHttpRequestObject=false;
function display(state_id)
{
if(window.XMLHttpRequest)
{
XMLHttpRequestObject=new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
XMLHttpRequestObject=new ActiveXObject("Microsoft.XMLHTTP");
} 
XMLHttpRequestObject.onreadystatechange=function()
{
if (XMLHttpRequestObject.readyState==4 && XMLHttpRequestObject.status==200)
{
document.getElementById("city").innerHTML=XMLHttpRequestObject.responseText;
}
}
XMLHttpRequestObject.open("GET","getcitylist.php?state_id="+state_id,true);
XMLHttpRequestObject.send();
}

This is my connection page

<?php
include("config.php");


$state_id=$_REQUEST['state_id'];


$query='SELECT tbl_city.*
FROM tbl_city
WHERE tbl_city.state_id ='';
echo $query;


?>

 <select id="city"  name="city" onChange="display(this.value)">
 <option value="" selected="selected">-- Select city --</option>
<?php

$query_result=mysql_query($query)or mysql_error();
while($row=mysql_fetch_array($query_result))
{
?>
<option value="<?php echo $row['id']; ?>"><?php echo $row['city_name']; ?></option>
<?php
}
?>

In the select query what should i display.In table city and table states I want to display city name taking state_id as common from both tables

Member Avatar for diafol
WHERE tbl_city.state_id ='';

Are you sure that's right?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.