如何将数据从php脚本传输到android并将它们存储为变量?

时间:2016-06-13 10:16:16

标签: php android mysql google-maps

我从服务器到php检索纬度和经度,我可以在对话框中显示它,但我想将它们存储为android中的变量。我怎么能这样做?

<?php
  $db_name = "sampledb";
  $mysql_user = "root";
  $mysql_pass = "";
  $server_name = "127.0.0.1";
  $a = mysqli_connect( $server_name, $mysql_user, $mysql_pass, $db_name );

  if( !$a )
  {
    echo"Connection error".mysqli_connect_error();
  }
  else
  {
    //echo"<h3>Successfull</h3>";
  }

  $bus = isset( $_POST["bus"] ) ? $_POST['bus'] : '';
  $sql_query = "select latitude, longitude from sample where bus like '$bus';";
  $result = mysqli_query( $a, $sql_query );

  if( mysqli_num_rows( $result ) > 0 )
  {
    $row = mysqli_fetch_assoc( $result );
    $latitude = $row["latitude"];
    $longitude= $row["longitude"];
    echo "bus latitude" . $latitude;
    echo "bus longitude" . $longitude;
  }
  else
  {
    echo "Bus cannot be tracked";
  }
?>

0 个答案:

没有答案