Converting Json database field to PHP array when reading column

QuestionsConverting Json database field to PHP array when reading column
Mark asked 6 years ago

Hi Abu,

I have a database column that contains a Json array and need to convert it so that each element of the array

can be displayed as a separate line in a grid.

For example the json column in the database might have the following:

[{“appName”:”A”,”appType”:3},{“appName”:”b”,”appType”:4}]

I would like for it to display appName and appType as the column headers with the appropriate data associated with it as editable rows.

Any thoughts and example code would be greatly appreciated.

 

Mark

1 Answers
Abu Ghufran Staff answered 6 years ago

Hi,

You can fetch this data from database using php-mysql standard functions and convert it in php array. This array can be supplied as datasource for grid.

To load grid from array, you can review demos/loading/load-array.php

Demo: https://gist.github.com/gridphp/af7ce29b851a125ad0af787ddd4d1dba

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

5 + 11 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?