access JSON results from wordpress database with wpdb (2 posts)

  1. Demetrius Pop
    Posted 2 years ago #

    I have JSON results from Google API added to to wp_options table. At this point I just need to echo the specific elements. Namely, the coordinates. The option_name I have is py_menu_item. One of the option_value element is coords. That is what represents the JSON results. The code below yields this response: array(o){}

    The code:

    global $wpdb;
    $myrows = $wpdb->get_results("SELECT coords FROM $wpdb->wp_options");
    $lat = $myrows->results[0]->geometry->location->lat;    //latitude
    $long = $myrows->results[0]->geometry->location->lng;   //longitude
    echo $lat;
    echo $long;

    I am using this Codex page as a guide: Class_Reference/wpdb

  2. catacaustic
    very awesome
    Posted 2 years ago #

    What do you get from var_dump($myrows)?

Topic Closed

This topic has been closed to new replies.

About this Topic