php - How to store JSON data in mysql database -


json data

 {"level":{"primary":"1","university":"3"},"sub":{"5":"literature","2":"bi","3":"maths"},"rate2":{"5":"20","6":"","7":"","9":"","2":"30","3":"50"},"name":"jessie","action":"test"} 

i need split data above , 3 tables.

1) tbl_user -columns(name)

2) tbl_user_level-columns(level,name)

3) tbl_subject_rate-columns(name,level,subject,rate)

basically need looping store them.how access json data , store them in mysql please?

i'm new json, detailed explanation , appreciated..thanks in advance.

edited:

i manage see array looks via var_dump($data) after decoding. shows below:

array (size=5)   'level' =>      array (size=2)       'primary' => string '1' (length=1)       'university' => string '3' (length=1)   'sub' =>      array (size=3)       5 => string 'literature' (length=10)       2 => string 'bi' (length=2)       3 => string 'maths' (length=5)   'rate2' =>      array (size=6)       5 => string '20' (length=2)       6 => string '' (length=0)       7 => string '' (length=0)       9 => string '' (length=0)       2 => string '30' (length=2)       3 => string '50' (length=2)   'name' => string 'jessie' (length=6)   'action' => string 'test' (length=4) 

how access, level, sub,rate2 , name handles' value?

try this:

$data = json_decode($return, true);  foreach($value['rate2'] $v=>$k) {   echo $v;   echo $k; } 

Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -