send json in mysql php code example
Example: 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";
}
?>