Parse JSON to mySQL

后端 未结 2 454
醉梦人生
醉梦人生 2021-01-07 11:44

A get in my PHP script JSON string that looks like this (array with any objects):

[
    {
        \"source\":\"symbols/2/2.png\",
        \"ypos\":133,
              


        
2条回答
  •  失恋的感觉
    2021-01-07 12:02

    Try this:

     $value) {
        if($value) {
    
                //how to use json array to insert data in Database
            mysql_query("INSERT INTO tablename (source, ypos, template) VALUES ($value->source, $value->ypos,$value->template)");
        }
        mysql_close($con);
    }
    

    Note: But it is recommended to use PHP Data Objects(PDO) to do database operations. Check here

提交回复
热议问题