Hello all,
I'm trying to have PHP draw up some results from a MySQL database, and format the results as XML. I've done this exact thing before, and it works out alright, however this time around, the XML is expecting something values that are giving me a bit of an issue...
The XML is expecting to get (lets just say) 5 rows from the database. This would work out just fine if there are actually 5 rows that fit the query (I can format them all with the right XML syntax no problem). The trick, here, is that I want to be able to write out 5 lines, just as the XML is expecting, even if the query doesn't result in 5 lines.
Take a look at an example of a normal result line, after PHP formats it and prints it out as XML:
<question value="What is my favorite color" answer="red" />
Then, if there are under 5 lines, I would like PHP to be able to add in a standard filler line, that would look something like this:
<question value="" answer="" />
This would essentially just be a placeholder. The last little issue (just to really complicate the issue), is that I would like to have those placeholders randomly ordered within the lines of real results. To give another example, take a look at the following possible XML printouts (R standing for result, P standing for placeholder):
1) RRRRR <--- no problems here, all are results as expected
2) RPRPR <--- PHP has to make up 2 placeholders, add them inbetween random lines
3) RRPPR <--- the same scenario, but since the PHP adds the placeholders in randomly, these placeholders are in a different position than example #2
Well, hopefully all of this makes sense. Thanks for reading, and I look forward to your replies.
-Ange52