I have three major tables in my database, called place, guideinfo and city. I enter a city name using a android app, and there is a cityID
associated with that city name. Each three tables have the cityID
column.
Below is my php:
<?php
$con=new mysqli("dsfsdf","fsfs","Wpraneet","a1575184_touri");
$city=$_POST['city'];
if($con->connect_error){
die( "Failed to connect MYSQL");
}
//$sql1="SELECT *
//FROM place, guideinfo, city
//WHERE place.city_cityID = city.cityID
//AND city.cityID = guideinfo.city_cityID
//AND place.city_cityID = guideinfo.city_cityID
//AND cityName = '".$city."'
//LIMIT 4;";
$sql1="SELECT * FROM place a JOIN guideinfo b ON a.city_cityID = b.city_cityID JOIN city c ON a.city_cityID = c.cityID WHERE cityName = '".$city."' LIMIT 4;";
$result1 = $con->query ($sql1);
if ($result1-> num_rows> 0) {
//output data of each row
while($row1 = $result1->fetch_assoc()) {
echo $row1['placeName'];
echo "_";
echo $row1['placeType'];
echo "_";
echo $row1['lat'];
echo "_";
echo $row1['lng'];
echo "_";
echo $row1['shtDes'];
echo "_";
echo $row1['GID'];
echo "_";
echo $row1['GName'];
echo "_";
echo $row1['Category'];
echo "_";
echo $row1['TelephoneNo'];
echo "_";
}
}
$con->close();
?>
In my app I want to retrieve data from four places and four guides in that city that has been entered and using google maps, mark those four places.
I have used two queries and both are mentioned in the code. My question is when there is only one tuple in guideinfo
table relevant to city which was entered, the map will show all the four markers on the map.
But if there are two tuples in the guideinfo
table relevant to city, the map will show two markers.
I want to show all the four markers and get details of four guides.
I think there must be a error in mysql query; what should I change?