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 | 1367 views | 3 replies

Jason ByrnesWebAssist

only the one recordset is needed.


Hers what you need to do:
Before the loop create a variable for the name, and set it to blank
<?php $nameStr = ""; ?>

inside the loop add an if statement to determine if the name tag should be written. and set the value of nameStr to the value ion the recordset.

the first time, you wont need to close the name tab, but subsequent times through, you will

php:
if($nameStr != $row_Recordset1['name']) {

  if($nameStr != "") fwrite($fp, '</item>');
  fwrite($fp, '<item Name="'.$row_Recordset1['name'].'">');
  $nameStr = $row_Recordset1['name'];
}



full code:

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 $nameStr 
""?>
<?php 
do {
if(
$nameStr != $row_Recordset1['name']) {
  if(
$nameStr != ""fwrite($fp'</item>');
  
fwrite($fp'<item Name="'.$row_Recordset1['name'].'">');
  
$nameStr $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>');
} while (
$row_Recordset1 mysql_fetch_assoc($Recordset1));
fwrite($fp'</item>');
?>
<?php
fwrite
($fp'</content>');
fclose($fp);
?>

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...