PHP Json array decode in php and inserting mysql -


this question has answer here:

"sci-6":{"quantity":11,"id":"sci-6","price":15,"name":"notebooks"}, "sci-7":{"quantity":1,"id":"sci-7","price":10,"name":"posters"}, "sci-8":{"quantity":2,"id":"sci-8","price":15,"name":"pen"}, "sci-9":{"quantity":4,"id":"sci-9","price":100,"name":"charger"}, "sci-10":{"quantity":1,"id":"sci-10","price":10.25,"name":"news paper"} 

please me decode variables , insert values mysql using php

$data = '{"sci-6":{"quantity":11,"id":"sci-6","price":15,"name":"notebooks"},"sci-7":{"quantity":1,"id":"sci-7","price":10,"name":"posters"},"sci-8":{"quantity":2,"id":"sci-8","price":15,"name":"pen"},"sci-9":{"quantity":4,"id":"sci-9","price":100,"name":"charger"},"sci-10":{"quantity":1,"id":"sci-10","price":10.25,"name":"news paper"}}';  $json_data=json_decode($data); foreach($json_data $json_value) {      mysql_query("insert yourtable (quantity, id, price, name) values ('".$json_value->quantity."','".$json_value->id."','".$json_value->price."','".$json_value->name."')");  } 

Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -