Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-29-2012, 10:33 PM   PM User | #1
mooserider2
New to the CF scene

 
Join Date: Apr 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
mooserider2 is an unknown quantity at this point
Arrow JSON to mysql with php

Ok I understand how to get normal JSON files into php variables with json_encode(); However, the json file I'm working with looks something like this:

Code:
{"daily":
{"1319846400000":250,"131993280000000",189"},"average":
{"1319846400000":190,"131993280000000",189"}}
There are 180 different daily prices with a 180 day running average (the long row of numbers is a timestamp in ms from Jan 1, 1970).

My question is how do I import this data into a table with id, timestamp, price, 180_average, one row per day?
mooserider2 is offline   Reply With Quote
Old 04-29-2012, 11:45 PM   PM User | #2
mooserider2
New to the CF scene

 
Join Date: Apr 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
mooserider2 is an unknown quantity at this point
Perhaps I could take the array made by json_decode() and do a foreach() but it is still nested strangely. Possibly a double foreach()? Like:

Code:
foreach($out["daily"] as $myarray) {
     foreach ($myarray as $key => $value) {
    
     }
}
I don't really know where to go from there. Possibly turn each part on the array into a string and put those strings into the database. How would I do that? Sorry I have been away from php for a while

http://www.webmasterworld.com/forum88/3811.htm this is what gave me the foreach() idea.
mooserider2 is offline   Reply With Quote
Reply

Bookmarks

Tags
json, mysql, php

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:07 PM.


Advertisement
Log in to turn off these ads.