PHP nested arrays to mysql

I need to extract certain data from external json into mysql. After decoding my json looks like this: Array ( [key1] => 1 [key2] => [key3] => Array ( [0] => Array ( [Id] => x1 [TimeStamp] =>y1 [Quantity] => z1 [Price] => q1 [Total] => w1 [FillType] =>e1 [OrderType] =>r1 ) [1] => Array ( [Id] =>x2 [TimeStamp] => y2 [Quantity] => z2 [Price] => q2 [Total] => w1 [FillType] => e1 [OrderType] => r2 ) [2] => Array .....and so on. I need to upload to my mysql three keys/values for each transaction, that is 'ID', 'TimeStamp', and 'Total'. I want to update that database every 5 minutes so that only data with newer 'TimeStamp' are added. Then I need to check the combined value of 'total' for the last 15 minutes, last (30-15) minutes, and value of 'total' for last 120 minutes divided by 8.

Hello, I send you some more info about what I need.
I want to make sure we understand eachother.

I download data from external server. It comes as json.
After after get_file_contents and json_decode true i receive nested arrays, which after print_r looks this way:

Array ( [success] => 1 [message] => [result] => Array ( [0] => Array ( [Id] => 111745476 [TimeStamp] => 2017-12-05T19:50:58.19 [Quantity] => 1.2 [Price] => 0.00857242 [Total] => 0.0102869 [FillType] => PARTIAL_FILL [OrderType] => SELL ) [1] => Array ( [Id] => 111745427 [TimeStamp] => 2017-12-05T19:50:56.113 [Quantity] => 0.10285719 [Price] => 0.0085831 [Total] => 0.00088283 [FillType] => FILL [OrderType] => BUY ) [2] => Array ( [Id] => 111745412 [TimeStamp] => 2017-12-05T19:50:54.787 [Quantity] => 0.41726852 [Price] => 0.00858651 [Total] => 0.00358288 [FillType] => FILL [OrderType] => SELL ) [3] => Array ( [Id] => 111745187 [TimeStamp] => 2017-12-05T19:50:46.83 [Quantity] => 19.13589601 [Price] => 0.00859 [Total] => 0.16437734 [FillType] => FILL [OrderType] => BUY )

and that is just a tiny part. I want to extract values from Id, TimeStamp and Total, where [0], [1], [2] are transactions on crypto exchange.
Then I want these to be transfered to mysql database every 5 minutes, but only with transactions that are newer (have bigger Id), so the old stay and new are added.

I use Bittrex exchange. You can see API here: https://bittrex.com/home/api

I will be using getmarkethistory with parameters

code looks like this

$uri='https://bittrex.com/api/v1.1/public/getmarkethistory?market=BTC-LTC'; that is Bitcoin-Litecoin market history
$ch = curl_init($uri);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('apisign:'.$sign));
$execResult = curl_exec($ch);
$obj = json_decode($execResult);

I will provide with apikey and apisecret if we come to an agreement.

My mysql database is called Bittrex. In that database there are tables with cryptocoin pairs. That is btc-ltc table, btc-xxx table, btc-yyy table and so on.
Each table has colums named Id, TableStamp and Total, where the ids, timestamps and totals for each transaction encoded in json should go.
I will need help with what type, atributes, and defaults should every column have (as for know Id is int, TimeStamp is timestamp NULL, and Total is decimal)

Next step is to summarize 'Total' values for last 15 minutes (let's call it A), for period between 30 and 15 minutes ago(let's call it B),
and average value for 15minute periods in last 2,5hours (2,5hours ago to 0.5 hours ago) - that's C

The new part I did not write about before is that if B is at least 3 times bigger than C, and A is bigger that B I want php to echo timestamp when 'if' was true and name of the pair of currencies.
For example: 2017-12-05T19:50:44.99 BTC-LTC. I want it stay on www page until restart (or just forever if its easier to do)
Additionally I want that to be sent to my FBmessenger.

I want to track more than 100 pairs of currencies. I don't need you to prepare all of those. I just need one pair, than I will copy/paste the code and
make necessary changes in json url, function name (is it a good idea to make a function called for example BTC-LTC? This way the function name could be echoed in messages?), table names and so on.

And last part: if it's possible I would like four values that is A (15 minutes), B (period between 30 and 15 minutes ago), C (2,5hours ago to 0.5 hours ago), and D(at lease X times bigger)
to be editable like a constant, same one for every function, so somewhere at the top of the php code.
I will run it on localhost.
Please feel free to ask questions.

Kemahiran: PHP

Lihat lagi: php nested menu mysql, nested sortable mysql php, php form email mysql, how to insert multiple array in mysql php, php create multidimensional array from mysql result, php sql result to multidimensional array, how to store multidimensional array in database, while loop multidimensional array php, php create multidimensional array from database, multidimensional array php mysql query, insert multidimensional array into mysql, php, mysql, data processing, php parse xml mysql, php soap webservice mysql, php form process mysql, php phone directory mysql, php form mail mysql, php script csv mysql

Tentang Majikan:
( 1 ulasan ) Poznań, Poland

ID Projek: #15808250

Dianugerahkan kepada:


Hello,client I'm interested in your job This is php script job. I'm expert of script I have built many php scripts. I can do in 1 day Please discuss more details via chat Thanks Relevant Skills and Experience Lagi

$120 USD dalam sehari
(36 Ulasan)

37 pekerja bebas membida secara purata $131 untuk pekerjaan ini


HI There, I can assist you with "PHP nested arrays to mysql", I have experience working with "similar Development". Let's have a quick chat to discuss it further. Relevant Skills and Experience I have been in this "P Lagi

$155 USD dalam 3 hari
(71 Ulasan)

I can create PHP script that will work like you want (parsing JSON, uploading it into MySQL, calculating totals etc) in less than 6 hours. Relevant Skills and Experience I have worked on similar projects dozens of tim Lagi

$90 USD dalam 0 hari
(269 Ulasan)

Hello, I am a senior web developer , with over 10 years of experiences. I am master of mysql database management and php script. I can help you asap. [login to view URL] Relevant Skills and Experience I am master Lagi

$155 USD dalam 3 hari
(28 Ulasan)
$155 USD dalam 3 hari
(54 Ulasan)

sir pm me im good in php i can finish this job fst Relevant Skills and Experience php Proposed Milestones $90 USD - price

$90 USD dalam 0 hari
(148 Ulasan)

I am a good web developer. I can do it. Relevant Skills and Experience php, json Proposed Milestones $155 USD - re

$155 USD dalam 3 hari
(33 Ulasan)

hi i read the requirement just one thing can you explain the 5 minute scenario which you are saying in the description Relevant Skills and Experience wordpress php Proposed Milestones $155 USD - final

$155 USD dalam 3 hari
(32 Ulasan)

Hi there, My name is Manish. I would like to write PHP script to save error and do the calculations over it. please get in touch to discuss more. Relevant Skills and Experience I have good proficiency in PHP, mysql Pl Lagi

$55 USD dalam 2 hari
(69 Ulasan)

12 Yrs. Exp. in Web Software Development. Available for work 8+ hours every day of week. [login to view URL] [login to view URL] [login to view URL] [login to view URL] Relevant Skills and Experience PHP MySql CodeIgniter Jquery3 Payment Gatewa Lagi

$35 USD dalam sehari
(34 Ulasan)
$70 USD dalam 2 hari
(91 Ulasan)

Hello there i am a professional and have extensive experience with these type of tasks, can you please pm me right now? i am waiting Thanks regards Relevant Skills and Experience php,mysql,json Proposed Milestones $1 Lagi

$112 USD dalam 4 hari
(24 Ulasan)

I have 100% job completion rate:) I have above 5yr of experience in Web Development & Designing, Web application development. Relevant Skills and Experience My strengths are in PHP, Codeigniter, Laravel, Wordpress, M Lagi

$150 USD dalam 3 hari
(17 Ulasan)

Please send me details. ......................................... Stay tuned, I'm still working on this proposal.

$90 USD dalam 2 hari
(33 Ulasan)

Five star technologies passion Relevant Skills and Experience I have 7 years experience with your project skills i'm specialist with your project project flow sir Proposed Milestones $120 USD - work Hi sir can you p Lagi

$120 USD dalam 3 hari
(42 Ulasan)

Hello Sir/mam, As a Web & App development company we have investigate your project and find that we can do this but first i would like to show u my exp. Relevant Skills and Experience Our specialities: - iOS/Android d Lagi

$155 USD dalam 3 hari
(25 Ulasan)

Hello, I can do it in few hours. Contact me if you want. Thanks

$160 USD dalam 0 hari
(28 Ulasan)

Hello I seen your array code as well description and we will done your issue ASAP, so can you come on chat and lets it star? Relevant Skills and Experience We have more the 8 years of working experience on web/mobile Lagi

$194 USD dalam 3 hari
(23 Ulasan)

We are passionate team of developers. Till now we have competed in the local market and now we are hitting to the online market as we want to expose our skills and expertise to the another level. Relevant Skills and E Lagi

$94 USD dalam 3 hari
(23 Ulasan)
$98 USD dalam 3 hari
(25 Ulasan)

We provides excellent services in satisfied price and on decided time. Relevant Skills and Experience *MS OFFICE,Typing *PHP,CodeIgniter,Laravel,MySQL,Angular,Javascript,JQuery,AJAX. *Native Android and IOS app develo Lagi

$150 USD dalam 3 hari
(10 Ulasan)