I want to make cron job on my server to save my json array every 10 minutes (I want to update mysql table every 10 minutes)
The thing is that i have really nasted array which is currently really hard for me to save alone without your help!
Here is the json array:
{"firstname":{"eur":14.27,"e":0.00612979},"lastname":{"eur":0.18709,"e":2.655e-05},"middlename":{"eur":617.26,"e":1.0}}
My table contain rows for: name (which is the name of the example-> firstname) So i want to update row where is the table name value same as on my example which is "firstname" or "lastname" or "middlename".
I have two more rows which contain "eur" and "e" rows. I must input values from json array to same line row as in the example. I know its bad explained what i want so i will try with better one.
In my SQL i have lines: (where name is already written and must stay same) Name - EUR - E
I want to update every 10 minutes the values of EUR and E where the NAME from sql is the same as in the array data.
Here is my not working PHP CODE:
$filename = "JSON-FILE-LINK";
$data = file_get_contents($filename);
echo $data;
Thank you so much community!
edit: I bet the sql code must be something like this: UPDATE names SET eur = $eur, e = $e, ... WHERE name = $firstname.
Firstname is the first name of the everyobject. And eur and e is the only values which must be changed.
How to populate json data to sql variables is the biggest problem now for me.