FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » PHP script after querying a DB
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
PHP script after querying a DB [message #175524] Tue, 04 October 2011 00:02 Go to next message
sandreev is currently offline  sandreev
Messages: 1
Registered: October 2011
Karma: 0
Junior Member
I am looking for a script that can output the data in the following
format.
Basically I am querying a DB to encode the output in a variation of
JSON format.

{
"cols": [
{"id":"","label":"Topping","pattern":"","type":"string"},
{"id":"","label":"Slices","pattern":"","type":"number"}
],
"rows": [
{"c":[{"v":"Mushrooms","f":null},{"v":3,"f":null}]},
{"c":[{"v":"Onions","f":null},{"v":1,"f":null}]},
{"c":[{"v":"Olives","f":null},{"v":1,"f":null}]},
{"c":[{"v":"Zucchini","f":null},{"v":1,"f":null}]},
{"c":[{"v":"Pepperoni","f":null},{"v":2,"f":null}]}
]
}

My approach is to store columns related array in variable1 and then
rows related array in variable2 and then print both. Any help in this
regard is highly appreciated.

thank you,
Re: PHP script after querying a DB [message #175526 is a reply to message #175524] Tue, 04 October 2011 01:30 Go to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 10/3/2011 8:02 PM, sandreev wrote:
> I am looking for a script that can output the data in the following
> format.
> Basically I am querying a DB to encode the output in a variation of
> JSON format.
>
> {
> "cols": [
> {"id":"","label":"Topping","pattern":"","type":"string"},
> {"id":"","label":"Slices","pattern":"","type":"number"}
> ],
> "rows": [
> {"c":[{"v":"Mushrooms","f":null},{"v":3,"f":null}]},
> {"c":[{"v":"Onions","f":null},{"v":1,"f":null}]},
> {"c":[{"v":"Olives","f":null},{"v":1,"f":null}]},
> {"c":[{"v":"Zucchini","f":null},{"v":1,"f":null}]},
> {"c":[{"v":"Pepperoni","f":null},{"v":2,"f":null}]}
> ]
> }
>
> My approach is to store columns related array in variable1 and then
> rows related array in variable2 and then print both. Any help in this
> regard is highly appreciated.
>
> thank you,

I don't think you'll find anything which will do what you want. But it
shouldn't be very hard to create such a script. What have you tried so far?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Basic php mysql user management (User management in cakephp)
Next Topic: anti aging skin products
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 09:45:54 GMT 2024

Total time taken to generate the page: 0.02434 seconds