i am trying to fetch latitude, longitude and venue by typing
sites[0] // gets latitude
sites[1] // gets longitude
sites[2] // gets venue
this is my code, dont mind the sql querrys, i know they are bad but it's functional for now. i just need help with this array:
var sites = [<?php
include_once'config/connect.php';
$search= $_POST['search'];
$search = stripslashes($search);
$search = mysql_real_escape_string($search);
$sql= "select * from venue where vID in (select vID from sv where sID in (select sID from sports where sN = '$search'));";
$result=mysql_query($sql)or die(mysql_error());
while($data=mysql_fetch_array($result))
{
echo ",[".$data['latitude']."]";
echo ",[".$data['longitude']."]";
echo ",[".$data['venue']."]";
}
?> ];
mysql_
methods; they're deprecated. 2. Don't try to format your JSON yourself, usejson_encode
. – kba Jan 9 at 12:37