close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Do while loop not adjusted for output

Thread began 5/05/2010 5:38 pm by tom92909 | Last modified 5/06/2010 12:40 pm by tom92909 | 1013 views | 3 replies

tom92909Beta Tester

Do while loop not adjusted for output

I've got a do while loop that I'm using to read a SQL query and then write a XML file to my server...

fwrite($fp'<?xml version="1.0" encoding="utf-8"?>');
do { 
fwrite($fp'<gallery Name="'.$row_Recordset1['name'].'">');
fwrite($fp'<image file="'.$row_Recordset1['directory'].'/'.$row_Recordset1['photo'].'">');
} while (
$row_Recordset1 mysql_fetch_assoc($Recordset1)); 

The above creates a properly formatted XML file that works with my application, however, if I have multiple records in the same <gallery> I need the loop to include all of the <image></image> records before closing the </gallery> and moving on to the next <gallery>

MySQL Query on the Gallery_contents Joining the Gallery listing ON gallery IDs.

mysql_select_db($database_ba, $dbconnect);
$query_Recordset1 = "SELECT * FROM gallery_content INNER JOIN gallery ON gallery.rec_id = gallery_content.gallery_id";
$Recordset1 = mysql_query($query_Recordset1, $dbconnect) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

The desired XML output example below would have (2) Gallery Groups with (2) photos in each group.

<?xml version="1.0" encoding="utf-8"?>
<gallery Name="Special Events">
<image file="Gallery2/sample1.jpg">
<image file="Gallery2/sample2.jpg">
<gallery Name="Just for Fun">
<image file="Gallery1/landscape.png">
<image file="Gallery1/portrait.png">

Do I create two loops here? I'm not sure how to accomplish this.

Thanks in advance.

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





Ease of use


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