- For individual users
- Instant access to solutions
- Ask your tech questions
- Start your 30-day Free Trial
Main Topics
Browse All TopicsI'm in an utter mind-melt and having started covering the same ground of problems I'm hoping you guys (from whom I've already learnt a lot) can help me.
I'm trying to get a PHP to build a section of XML from a MySQL table.
The end-result should look something like this:-
--------------------------
Code:
<Monkey_Muffin>
<R0>
<C0>
<section width="200" height="75" lineThickness="0" lineColour="0x333333"/>
<text>
<txt1 />
<txt2 text="Monkeys" y="2" font="Myriad Pro" fontSize="12" fontColour="0xFFFFFF" align="left" />
<txt3 text="I like them" y="15" />
</text>
<image>
</image>
</C0>
<C1>
<section width="75" height="75" lineThickness="0" lineColour="0x333333" lineAlpha="100" />
<text>
</text>
<image src="Monkey_Muffin.jpg" fit="false" width="70" height="70" x="2.5" y="2.5" alpha="100" />
</C1>
</R0>
</Monkey_Muffin>
--------------------------
The table in the MySQL DB contains:-
--------------------------
Code:
Field Type Null Default
name varchar(20) Yes
id int(11) Yes
row int(11) Yes
section int(11) Yes
width int(255) Yes
height int(255) Yes
lineThickness int(255) Yes
lineColour varchar(255) Yes
lineAlpha int(255) Yes
--------------------------
and a few other bits and pieces...
Baring in mind that there could be multiple rows and multiple sections/columns within rows
What I'm trying to get the PHP to do is start
* ID1 - print the name
* In ID 1 - where row 1 (in XML terms here, not SQL), print all buttons rows (in SQL terms here)
* then move onto row 2 until no further rows
* then repeat process for next ID
In the format outlined above. I have got this working for simpler examples, and I'm thus trying to use code from those... but it's much more complicated. I'm currently trying:-
Code:
--------------------------
<?php
        $dbh = mysql_connect("xxx", "xxx", "xxx");
        mysql_select_db("xxx");
        $query = "SELECT * FROM table WHERE id = 1"; // get cycle up on this
        $result = mysql_query($query, $dbh);
        $fields = mysql_num_fields($result);
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
while ($row=mysql_fetch_array($r
for ($i=0; $i<$fields; $i++) {
$name=mysql_field_name($re
if ($row['id']= 1) { // get this number to come from earlier variable
if ($row['row']= 1) { // get this number to cycle upwards until done
if ($row['section']= 1) {
echo "<$name=\"$row[$name]\" />\n"; }
else { echo "can put a stop on this for end of row"; }
}
else { echo "row not 0"; }
}
else {
echo "not showing";
}
}
echo "/>\n<";
}
?>
--------------------------
Admittedly with hard-coded ID etc. atm just to see if I can get it working. I can get bits working with bits of info, but I think I'm on completely the wrong road.
Any directional help would be really great.
This question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership