WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. Demetrius Pop
    Member
    Posted 9 months 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;
    var_dump($myrows);

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

  2. catacaustic
    Member
    Posted 9 months ago #

    What do you get from var_dump($myrows)?

Reply

You must log in to post.

About this Topic