display city_name using two tables. I have written two queries but unable to display the results. First Table name is tbl_city and it has id,state_id,city_id,city_name. Other table name is tbl_states and it has id,state_id,state_name

$state_id=$_REQUEST['state_id'];
$query="select c.city_name FROM tbl_city AS c,tbl_states AS s where c.state_id='$state_id' AND  s.state_id='$state_id'";(two tables using alias)
$query="select tbl_city.city_name FROM tbl_city INNER JOIN tbl_states ON tbl_states.state_id='$state_id' AND tbl_city.state_id='$state_id'";(using Inner join)

Only you need one query as following

$state_id=$_REQUEST['state_id'];

$query="select tbl_city.city_name,tbl_states.state_name  FROM tbl_city INNER JOIN tbl_states ON  AND tbl_city.state_id=tbl_states.state_id where tbl_states.state_id='$state_id' "
Be a part of the DaniWeb community

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