php - Formatting Arrays for json_encode -
I'm looking for days to try and piece together my solution, but still struggling I am I am struggling with some PHP and want to format it in Jason-Encoded so that I can use Nakout.JS.
I have a DB that looks like this:
| ID | Name | Price | | 1 | Action Name | First Work | | 1 | Workdays | Enter your first task. | 1 | Agenda | Very important. | 2 | Action Name | Second task. | 2 | Workdays | Enter your second task. | 2 | Agenda | Important | I am trying to get this response on my site with json_encode:
[{"id": "1", " "Work name": "first work", "workday": "enter your first work", "agenda": "very important"}, {"id": "2", "function name": "second task", " Even today I have:
code> $ user = 1; $ Task_sql = "Select * FROM` li_id` at INNER li_id.id = li_details` on li_details.id WHERE li_id.user = '". $ User =' $ '= $ mysql_query ($ work_scl, $ conn); $ result = array (); while ($ line = mysql_fetch_assoc ($ result)) {$ result [] = Array ($ line ['name'] = & gt; $ line ['value']);} Echo json_encode ($ result); Feedback:
The problem is that I get to the group ID in different arrays, will not be able to figure it out. I have tried many things, but any suggestion or direction for other threads without any fate would be horrible. Thanks!
About something like this:
while ($ $ Result [$ row ['id']] = array (); $ result [$ row ['id'] $ {if (! Isset ($ result [$ row ['id']] ']] [$ Row [' name ']] = $ row [' value ']); } After that you will have next to all the fields in your ID after json_encode
Comments
Post a Comment