Answers for "how to insert json data into mysql using php"

PHP
0

how to insert json data into mysql using php

<?php 

$josndata = '{
"student":{ "name":"Harry", "country":"United State", "ContactNo":2545454 }
}';  

// Database connection
$conn = new mysqli('localhost', 'username', 'password', 'databasename');

// Insert data Query
$sql = "INSERT INTO student_table ( name, jsondata )
VALUES ('Harry', '$josndata')";

if ($conn->query($sql) === TRUE) {
  echo "Insert your JSON record successfully";
} 
?>
Posted by: Guest on July-06-2020

Code answers related to "how to insert json data into mysql using php"

Browse Popular Code Answers by Language