PDA

View Full Version : PHP XML MySQL news/gigs reader in flash


high1memo
02-18-2005, 03:05 AM
Hi All,

I'm doing a MySQL <-> PHP -> XML -> Flash app - in this case to read and list a bunch of gigs (or news) stored in a MySQL DB - and I have a question. I know how to do it all, but I just want a tip from someone who has some experience in this area. My question is, should I make all of the properties of the gigs as attributes or child nodes or mixed?

I.e. in PHP, should I format my XML file as:

echo "<gig>";
echo "<date>$fdate</date>";
echo "<venue>$venue</venue>";
echo "<promoter>$promoter</promoter>";
echo "<address>$address</address>";
echo "<city>$city</city>";
echo "<postcode>$postcode</postcode>";
echo "<country>$country</country>";
echo "<details>$details</details>";
echo "</gig>";

OR

echo "<gig date='$fdate' venue='$venue' promoter='$promoter' address='$address' city='$city' postcode='$postcode' country='$country'>$details</gig>";

I know there is no CORRECT answer, but like I said, I just want some advice from someone who has already done similar stuff, and has found one way to be easier.

To me, it seems like the first one would be a lot more suitable if I was just gonna load this XML straight into a CSS assigned textbox (which is what I do with my guestbook). But for this, I actually want to use the information a bit differently as well, e.g. on the home page I want to display the closest gig etc, so I need more of a database functionality - so the 2nd way seems easier. I.e. instead of browsing through loads of child nodes, I can just access all the attributes throught the XMLNode.attributes.

So anyways, if anyone has any advice, would be much appreciated,


On another note (maybe I should post this as another thread?), if I were to go with the first route (which I actually do for my guestbook), is there a quick 1or2 command way to convert a sqlquery record straight to an xml entry? instead of reading field by field and manually doing it (like I did in the example above). Or better still, converting an entire sqlquery into an xml without cycling through all the records?

cheers