Skip to content
Advertisement

How to create a custom JSON layout from MySQL in PHP

I have a MySQL query in PHP that pulls back two columns of results

Column One is Label Column Two is Value

I have read http://nitschinger.at/Handling-JSON-like-a-boss-in-PHP but im struggling to understand how I can do the following JSON in PHP from MySQL

JavaScript

I can manually write a loop to output the raw text to form a JSON like above but I really want to use json_encode

JavaScript

Can this be done? if so how?

Advertisement

Answer

Try this:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement