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:
global $wpdb; $myrows = $wpdb->get_results("SELECT coords FROM $wpdb->wp_options"); $lat = $myrows->results->geometry->location->lat; //latitude $long = $myrows->results->geometry->location->lng; //longitude echo $lat; echo $long; var_dump($myrows);
I am using this Codex page as a guide: Class_Reference/wpdb
- The topic ‘access JSON results from wordpress database with wpdb’ is closed to new replies.