JSON data into Mysql using PHP [closed]

2 weeks ago 17
ARTICLE AD BOX

Have a very large JSON dump file from a vendor of my golf stats for 2025. Trying to get it inserted into Mysql using PHP. The data seems to be multi-leveled. I have tried a number of snippets that I've found on StackOverflow and other places, but the format my data is in doesn't quite match what the articles I've found.

{ "rounds": [ "share_id": "h7ERkA", "started_at": "2021-06-06 16:03:55 UTC", "ended_at": "2021-06-06 20:50:05 UTC", "input_mode": "simple", "scoring_mode": "stroke_play", "course": { "name": "WinterStone Golf Course (18)" }, "tee": { "name": "white" } ] }

The snippet of code that I found to try and parse the file and insert the data into a mysql database table:

$file = 'hole19.json'; $jsondata = file_get_contents($file); $data = json_decode($jsondata, true); foreach ($data as $row) { $id = $data['rounds']['share_id']; // Doesn't work $id = $data['share_id']; // Doesn't work either }

I can't even get it to assign to the variable. None of the JSON examples I've seen have the data in this format.

Read Entire Article