Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

Demetrius Pop on "access JSON results from wordpress database with wpdb"

$
0
0

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


Viewing all articles
Browse latest Browse all 8245

Trending Articles