Tratando dados Retornados do MySQL+PHP com JQuery


    var id = $(this).attr('id');
    $.get("functions.php?func=getLatLong&car=" + $(this).val(), function(dadosRetornados){
      $.each($.parseJSON(dadosRetornados), function (key, value) {
        $("#" + id).after(value.latitude,value.longitude);


function getLatLong($car){

  $link = mysql_connect('localhost', 'root', 'passwd') or die(mysql_error());
  mysql_select_db('db') or die(mysql_error());

  $query = "SELECT latitude, longitude
                FROM table
                LIMIT 1";

  $result = mysql_query($query) or die(mysql_error());

  while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {

    $arr["{$row['dados']}"]['latitude'] = $row['latitude'];
    $arr["{$row['dados']}"]['longitude'] = $row['longitude'];

  echo json_encode($arr);

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s