<?php
require_once('../connect/connect.php');
include_once('../lib/lib.php');

header('Content-Type: text/html; charset=utf-8');
if($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest') {

$json = '{markers:['."\n";

$query1= "SELECT * FROM qiwiterminal";
$result1 = mysql_query($query1);

if(mysql_num_rows($result1)>0)
{
while ($par1 = mysql_fetch_array($result1)){

$cname =  'Теминал QIWI';

$exp_str = explode(",", $par1['coords']);

$lat = $exp_str[0];

$lng = $exp_str[1];

$json.= "\n".'{'.'"id": "'.$par1['id'].'",';

$json.= '"cname": "'.$cname.'",';

$json.= '"address": "'.$par1['address'].'",';
    
$json.= '"lat": "'.$lat.'",';

$json.=  '"lon": "'.$lng.'"';

$json.= '},';

}

$json = substr($json, 0,-1);

echo  $json;

echo '], ', "\n",  '"status": "OK"', "\n", '}';

}
else
{
echo '{"status": "false"}';
}

}

?>