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' "

I think the ON AND in the above post should just be ON.

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.