dongtao9158 2015-06-03 17:52
浏览 58

使用php从android检索数据库中的数据

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?

  • 写回答

1条回答 默认 最新

  • dongshandun4363 2015-06-03 18:06
    关注

    I have trouble following your description of the problem.

    Can you tell me more specific how your expected result looks like? I don't see how you want details of 4 guides when only 2 are available.

    评论

报告相同问题?

悬赏问题

  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来