Linked Questions

Popular Questions

MySQL Query on Google Map PHP

Asked by At

I want to do the query based on HTML form input to my google map API,

I want to do the query based on HTML form input to my google map API, The HTML Form which i want to be used are 'provinsi' and 'kota'

that's why i used the MySQL Query as

"SELECT * FROM table_p WHERE nama_provinsi='".$nama_provinsi."' AND nama_kota='".$nama_kota."' ";

the field in 'table_p' i want to use are 'nama_provinsi' and 'nama_kota'

the PHP query script is

<?php
 require("koneksi.php");

 $nama_provinsi = $_POST['provinsi'];
 $nama_kota = $_POST['kota'];
 $jenis = $_POST['jenis'];
 $harga1 = $_POST['number1'];
 $harga2 = $_POST['number2'];

 function parseToXML($htmlStr)
  {
   $xmlStr=str_replace('<','&lt;',$htmlStr);
   $xmlStr=str_replace('>','&gt;',$xmlStr);
   $xmlStr=str_replace('"','&quot;',$xmlStr);
   $xmlStr=str_replace("'",'&#39;',$xmlStr);
   $xmlStr=str_replace("&",'&amp;',$xmlStr);
   return $xmlStr;
  }

 $connection=mysqli_connect ($db_host, $db_user, $db_pass);
 if (!$connection) {
     die('Not connected : ' . mysqli_error());
 }

 $db_selected = mysqli_select_db($connection,$db_name);
 if (!$db_selected) {
  die ('Can\'t use db : ' . mysqli_error());
 }

 $query = "SELECT * FROM table_p WHERE nama_provinsi='".$nama_provinsi."' AND nama_kota='".$nama_kota."' "; 

 $result = mysqli_query($connection,$query);
 if (!$result) {
   die('Invalid query: ' . mysqli_error());
 }

 header("Content-type: text/xml");

 echo "<?xml version='1.0' ?>";
 echo '<table_p>';
 $ind=0;

 while ($row = @mysqli_fetch_assoc($result)){

   echo '<marker ';
   echo 'id="' . $row['id'] . '" ';
   echo 'Properti="' . parseToXML($row['Properti']) . '" ';
   echo 'Alamat="' . parseToXML($row['Alamat']) . '" ';
   echo 'Luas="' . parseToXML($row['Luas']) . '" ';
   echo 'Harga="' . parseToXML($row['Harga']) . '" ';
   echo 'status="' . parseToXML($row['status']) . '" ';
   echo 'Fasilitas="' . parseToXML($row['Fasilitas']) . '" ';
   echo 'Nama="' . parseToXML($row['Nama']) . '" ';
   echo 'Kontak="' . parseToXML($row['Kontak']) . '" ';
   echo 'lat="' . $row['lat'] . '" ';
   echo 'lng="' . $row['lng'] . '" ';
   echo '/>';
 $ind = $ind + 1;
 }

echo '</table_p>';

?>

my expectation is, currently i have data for all province (Provinsi) and all city (Kota), by do this query i want to display the data in certain Province and City based on HTML form input

Related Questions