close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Using DataAssist Query to export to XML

Thread began 5/20/2010 5:30 pm by tom92909 | Last modified 5/21/2010 2:34 pm by tom92909 | 1350 views | 3 replies

tom92909Beta Tester

Using DataAssist Query to export to XML

I have a DataAssist query that is working.
I have a fwrite to XML export process using same DataAssist query working, but not as desired.

php:
<?php
mysql_select_db
($database_dbconnect$dbconnect);
$query_Recordset1 "SELECT * FROM mytable GROUP BY name";
$Recordset1 mysql_query($query_Recordset1$dbconnect) or die(mysql_error());
$row_Recordset1 mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 mysql_num_rows($Recordset1);
?>
<?php
$fp 
fopen('example.xml''w+');
fwrite($fp'<?xml version="1.0" encoding="utf-8" ?>');
fwrite($fp'<content>');
?>
<?php 
do {
fwrite($fp'<item Name="'.$row_Recordset1['name'].'">');
fwrite($fp'<image="'.$row_Recordset1['image'].'">');
fwrite($fp'<text>');
fwrite($fp'<![CDATA[Lorem ipsum dolor sit amet, consectetuer.]]>');
fwrite($fp'</text>');
fwrite($fp'</image>');
fwrite($fp'</item>');
} while (
$row_Recordset1 mysql_fetch_assoc($Recordset1));
?>
<?php
fwrite
($fp'</content>');
fclose($fp);
?>




What I expect as a result is something like this...

html:
<?xml version="1.0" encoding="utf-8" ?>
<content>
<item Name="FRUIT">
<image="apple.jpg">
<text>
<![CDATA[Lorem ipsum dolor sit amet, consectetuer.]]>
</text>
</image>
<image="orange.jpg">
<text>
<![CDATA[Lorem ipsum dolor sit amet, consectetuer.]]>
</text>
</image>
<image="pear.jpg">
<text>
<![CDATA[Lorem ipsum dolor sit amet, consectetuer.]]>
</text>
</image>
</item>
<item Name="Animals">
<image="dog.jpg">
<text>
<![CDATA[Lorem ipsum dolor sit amet, consectetuer.]]>
</text>
</image>
<image="cat.jpg">
<text>
<![CDATA[Lorem ipsum dolor sit amet, consectetuer.]]>
</text>
</image>
</item>
<item Name="Flowers">
<image="rose.jpg">
<text>
<![CDATA[Lorem ipsum dolor sit amet, consectetuer.]]>
</text>
</image>
<image="daisy.jpg">
<text>
<![CDATA[Lorem ipsum dolor sit amet, consectetuer.]]>
</text>
</image>
</item>
</content>



If I use ORDER BY in stead of GROUP BY I get something closer to what I'm looking for, but it needs only to send the <item> only once per/match.

I think my query is the problem... What I'm getting instead of the above desired result is only the first record of each ("GROUP BY") <item> name. Which is exactly what the query is asking for...I need to write this XML file to match up all of the records that have the same names, write those records close that </item> and then move to the next set of <item> name matches and so on until the query is done.

What am I missing here?

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...