MySQL Data to JSON with PHP Fetch Array & Fetch Assoc

By Code Wall - 2018-05-26

Description

How to convert MySQL data objects to JSON whilst using PHP functions Fetch Array and Fetch Assoc. All examples are included.

Summary

  • A Simple Example for Converting MySQL Data Result to JSON with PHP Generally, most PHP applications work with MySQL as the back-end database and within PHP we can extract the data via the MySQLi class.
  • The important piece of code within the following script is json_encode, this is where the magic happens.
  • Check out the json_encode function on the PHP documentation for further reading.

 

Topics

  1. Database (0.24)
  2. Backend (0.18)
  3. Coding (0.14)

Similar Articles

How to Fetch Data in React: Cheat Sheet + Examples

By freeCodeCamp.org - 2021-02-12

There are many ways to fetch data from an external API in React. But which one should you be using for your applications in 2021? In this tutorial, we will be reviewing five of the most commonly used ...

15 Essential Steps To Build Reliable Data Pipelines

By Medium - 2020-12-01

If I learned anything from working as a data engineer, it is that practically any data pipeline fails at some point. Broken connection, broken dependencies, data arriving too late, or some external…

Using AWS Lambda for streaming analytics

By Amazon Web Services - 2020-12-15

With tumbling windows, you can calculate aggregate values in near-real time for Kinesis data streams and DynamoDB streams. Unlike existing stream-based invocations, state can be passed forward by Lamb ...