View Single Post
Old 05-20-2008, 11:40 AM   #8 (permalink)
sketchMedia
The Prestige
Advanced Programmer Top Contributor Good Samaritan 
 
sketchMedia's Avatar
 
Join Date: Oct 2007
Location: Manchester, UK
Posts: 836
Thanks: 31
sketchMedia is on a distinguished road
Default

hi m8, glad you liked it.

the problem (as far as i can see) as that the 'foreach' loop is outside of the 'while'.

fixed:
PHP Code:
<?php
require_once("Connections/Connection.php"); // Database Connection
include("Function/Dateswapper.php"); // Dateswapper function

/////
$query sprintf("SELECT * FROM `clients` LIMIT %d, %d"$rowstart$limit);
$result = @mysql_query($query);
/////

$doc = new DomDocument('1.0');
$root $doc->appendChild($doc->createElement('profiles'));  
while(
$row = @mysql_fetch_array($result))
{
    
// add node for each record
    
$clients $root->appendChild($doc->createElement('clients'));
    foreach(
$row as $fieldname => $fieldvalue)  
    {  
        
$clients->appendChild($doc->createElement($fieldname$fieldvalue));  
    }  
}  
echo 
'Wrote: ' $doc->save("clients.xml") . '  bytes';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Untitled Document</title> 
</head> 

<body> 
</body> 
</html>
that should work, I fixed your sprintf and shortened the script abit.
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
sketchMedia is offline  
Reply With Quote