Hello everybody, I make a function that lets you convert a recordset
obtained via mysql_query() into an XML string:
maybe could be helpfull to yours

this is the function

it have 3 parameters:   $rs is the recordset you want to convert
                                    $padre is the name for the parent node
that will contain every record on the recordset
                                    $hijo is the name for the child node
that will contain a single record in the recordset



function rs2xml($rs,$padre,$hijo){
 $num_campos=mysql_num_fields($rs);
 $num_filas=mysql_num_rows($rs);

 if($padre!="-1")
  $xml="<$padre>\n";
 else
  $xml="";

 $cont1=0;
 while($cont1<$num_filas){
  $fila=mysql_fetch_array($rs);
  $xml.="<$hijo>\n";
  $cont=0;
  while($cont<$num_campos){
   $nombre_campo=mysql_field_name($rs,$cont);
   $valor_campo=$fila[$cont];
   $xml.="<".$nombre_campo.">".$valor_campo."</".$nombre_campo.">\n";
   $cont++;
  }
  $xml.="</$hijo>\n";
  $cont1++;
 }
 if($padre!="-1")
 $xml.="</$padre>\n";
 return $xml;
}

I hope this will be helpful for you

OCTAVIO HERRERA



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to