et4891 Posted October 3, 2013 Share Posted October 3, 2013 I have three text box for people to enter as numbers and stores in json <?php add_option('angels_'.date("ymd-His"), json_encode($_POST)); ?> The data stored in the database looks like {"angle1":"60","angle2":"60","angle3":"90","submit":"Submit"} the above is also what I get what I called out the data from the database I used this code to call out the data <?php $sql = "SELECT * FROM wp_options WHERE option_name LIKE 'angels%' ORDER BY option_name"; $options = $wpdb->get_results($sql); foreach ( $options as $option ) { esc_attr($option->option_value).PHP_EOL; } $values = esc_attr($option->option_value); echo $values; ?> The output gives me {"angle1":"60","angle2":"60","angle3":"90","submit":"Submit"} if I only want to get the numbers 60/60/90 individually how can I do that? Quote Link to comment Share on other sites More sharing options...
vinny42 Posted October 3, 2013 Share Posted October 3, 2013 How about json_decode()? :-) Or use a database that can deal with JSON, like PostgreSQL. Quote Link to comment Share on other sites More sharing options...
Solution et4891 Posted October 3, 2013 Author Solution Share Posted October 3, 2013 How about json_decode()? :-) Or use a database that can deal with JSON, like PostgreSQL. so I should do something like below? $options = json_decode($wpdb->get_results($sql),true); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.