To clarify, do you want each element of the rowdata array to contain a string that looks similar to the one you show at the top, or does that show strings for the first four elements of the array, or do you intend it to be a two-dimensional array where each element contains a further array? If it’s the second of those, would this do it?
I’m confused that there’s a comma just before the close square-brace in the first but not in any of the others. Also there’s probably a way to do the above without repeatedly opening and closing quotes. And the data in your table doesn’t seem to be the same as in the sample of what you need - there’s no row where ‘l_id’ has a value of 1 but I assume that’s not relevant.
If the above doesn’t help, can you clarify exactly what “no luck” means - doesn’t run, runs but gives errors, runs but doesn’t produce what you want, and so on?
So does the code I put above get any closer? And if not, what happens, do you get error messages?
Sorry, but I’m on limited bandwidth so haven’t really got enough spare to go off around the web reading up on your specifications, but happy to try to help if you post on here what you’re trying to achieve and exactly what problems you’re having.
You don’t need to create the JSON by hand as you’re doing here, the json_encode function will convert associative arrays into JSON objects, and numeric arrays into JSON arrays.