tags:

views:

48

answers:

3

hi there i have a question and need help on this from you guys .

I have a database created for a game called gamesleaderboard and the fields are id, player_name, score, leveltime. and my task is after getting the score, i have to insert it to a database and sort the dbase accordingly. after sorting, the code will return an xml in the following structure:

Ahmad100080 Basel95090 Samer920100 Seyd900110 Ahmad100080 Basel95090 Samer920100 Seyd900110 Ahmad100080 Basel95090

plz tell me the necessary details how to do this thankyou.

+2  A: 

In most simplistic terms there is nothing really special to do here, you can output XML in exactly the same way you would output HTML in PHP, this is a simple example

You can also use the DOMDocument class (or SimpleXML) to output XML, this is a bit more complex but is better practice. For an example of creating XML with DOMDocument using data from MySQL read more here

seengee
Agreed. If you can sort it into an array, you can "print" an XML document by just looping through the array.
Joseph
A: 

Don't forget to send the correct Content-Type header before outputting the XML document tho.

CharlesLeaf
A: 

If you are very new to XML I would highly recommend SimpleXML as it will be enough for most of needs. Creating XML using "echo" and strings is not only a dangeous but also a very bad programming technique.

Using SimpleXML you can easily add new nodes, adding child nodes and attributes to them. If you can getting started reading the PHP docs, just search for a SimpleXML tutorial on google. Or ask your questions right here.

Kau-Boy