Home Json How to change MySQL data in JSON format?

How to change MySQL data in JSON format?

by therichpost
0 comments
mysql-select-query

Hello to all, welcome to therichpost.com. In this post, I will tell you How to change MySQL data in JSON format? When we want to send data one page to other page then we can use json formatted data. We will save Mysql data in json format.
We can this json formatted data jquery ajax request get or post.

Please check the working example of change MySQL data in JSON format:

$con=mysqli_connect($servername,$username,$password,$databasename);
if (mysqli_connect_errno())
{
echo “Connection Error” . mysqli_connect_error();
}
$query = “SELECT * FROM TableName”;
$result = mysqli_query($con,$query);
$querydata = array();
while($data = mysqli_fetch_array($result)) {
$querydata[] = $data;
}
echo json_encode($querydata);
mysqli_close($con);

There are so many queries in Mysql and I will let you know all. Please do comment if you any query related to this post. Thank you. Therichpost.com

You may also like

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.