将多维php数组插入mysql表

This is the multidimensional array i have. I am new to Php ..i want to input the name,folderid and upload at into an sql table but am stuck at the array part. i need help

Array
(
[status] => 200
[msg] => OK
[result] => Array
    (
        [folders] => Array
            (
                [0] => Array
                    (
                        [id] => 1861013
                        [name] => .videothumb
                    )

            )

        [files] => Array
            (
                [0] => Array
                    (
                        [name] => wildlife.mp4
                        [cblock] => 
                        [sha1] => d5d4e1001f98f70324ef4f84ccd6d683f653c513
                        [folderid] => 1861011
                        [upload_at] => 1487016733
                        [status] => active
                        [size] => 558253404
                        [link] => link here
                        [download_count] => 0
                        [cstatus] => ok

                    )

            )

    )

)

here is the mysql insert code that i tried to use to insert data into the table but all i get in the database are zeros

 $st = $dbh->prepare("INSERT INTO movies(name, upload_at, link, folderid)     
  VALUES (:field1, :field2, :field3, :field4)");


 // bind variables to insert query params

      $st->bindParam(1, $name);
      $st->bindParam(2, $uploadat );
      $st->bindParam(3, $link);
      $st->bindParam(4, $folderid);




  $json = file_get_contents($filename);   

//convert json object to php associative array

$data = json_decode($json, true);





// loop through the array
foreach ($data as $item) 
 {  $name = $item['result']['folders'][0]['id'];
  $uploadat = $item['result']['files'][0]['upload_at']; 
  $link = $item['result']['files'][0]['link']; 
  $folderid = $item['result']['files'][0]['folderid'];   

    echo $name;
    echo $folderid;
    // execute insert query
    $st->execute(array(':field1'=>$name,
                       ':field2'=>$uploadat,
                       ':field3'=>$link,
                       ':field4'=>$folderid));
}

Because the array structure doesn't nest the files subarray inside of the folders subarray, I am assuming that folders' indices correspond with files' indices.

foreach($data["result"]["folders"] as $index=>$subarray){
    $st->execute(array(':field1'=>$subarray["id"],
                       ':field2'=>$data["result"]["files"][$index]["uploadat"],
                       ':field3'=>$data["result"]["files"][$index]["link"],
                       ':field4'=>$data["result"]["files"][$index]["folderid"]));
}

Suspiciously, $data["result"]["files"][$index]["folderid"] doesn't match $subarray["id"] in your sample array.

This snippet will need to be modified if a array_search() for folderid is required.