Posted inphp / Mysql / Mysqli

how to store json data in mysql using php?

Today, We want to share with you how to store json data in mysql using php.In this post we will show you json to mysql php, hear for fetch json data and insert into mysql table in php we will give you demo and example for implement.In this post, we will learn about php mysql store json with an example.

How to Insert JSON Data into MySQL using PHP?

What is JSON File Format?

JSON file simple data contains details stored in JSON format as well as has the extension of “*.json”. JSON stands for JavaScript Object Notation as well as is a light weight data interchange format. Being less cluttered as well as more readable than XML, it has become an simply alternative main json data format to store as well as interchange data. All latest browsers supports like a fresh JSON format.

here bellow we will display simple Example of a JSON File.

memberdetails.json

{
    "memberid": "SJ011MS",
    "memberdtl": {
        "name": "Virat Kohali",
        "gender": "Male",
        "age": "29",
        "location": {
            "streetlocation": "7 24th Street",
            "city": "India",
            "state": "IN",
            "zipcode": "20038"
        }
    },
    "profile": {
        "appointment": "Dipti Shah",
        "sector": "Computer"
    }
}

Step 1: Connect PHP to MySQL Database


Step 2: Read the JSON file in PHP


Step 3: Convert JSON String into PHP Array


Step 4: Extract the Array Values


Step 5: Insert JSON to MySQL Database with PHP Code


Full PHP Script

index.php


I hope you get an idea about php mysql store json.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I'm a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.

Leave a Reply

Your email address will not be published. Required fields are marked *

We accept paid guest Posting on our Site : Guest Post Chat with Us On Skype