Foros del Web » Programando para Internet » PHP »

Sistema de Comentarios PHP Mysql XML

Estas en el tema de Sistema de Comentarios PHP Mysql XML en el foro de PHP en Foros del Web. Hola que tal! Les escribo por que estoy generando un scritp el cual contienen varios archivos para crear un sistema de comentarios en php para ...
  #1 (permalink)  
Antiguo 25/04/2010, 01:52
 
Fecha de Ingreso: marzo-2009
Mensajes: 9
Antigüedad: 15 años, 1 mes
Puntos: 0
Sistema de Comentarios PHP Mysql XML

Hola que tal!

Les escribo por que estoy generando un scritp el cual contienen varios archivos para crear un sistema de comentarios en php para mandar saludos.

Tengo un archivo flash llamado mensajes.swf

el cual contiene el siguiente codigo.

Código PHP:
// Action script...

// [Action in Frame 1]
function cargarDatos(_indice)
{
    var 
_loc3;
    var 
_loc2;
    var 
_loc4;
    var 
_loc6;
    var 
_loc7;
    var 
_loc5;
    var 
_loc8;
    var 
_loc10;
    var 
_loc11;
    var 
_loc9;
    
_loc3 mensajes_xml.firstChild.childNodes[0].firstChild.nodeValue;
    
_loc2 mensajes_xml.firstChild.childNodes[1].firstChild.nodeValue;
    
_loc4 mensajes_xml.firstChild.childNodes[2].firstChild.nodeValue;
    
_loc6 mensajes_xml.firstChild.childNodes[3].firstChild.nodeValue;
    
_loc7 mensajes_xml.firstChild.childNodes[4].firstChild.nodeValue;
    
_loc5 mensajes_xml.firstChild.childNodes[5].firstChild.nodeValue;
    
_loc8 mensajes_xml.firstChild.childNodes[6].firstChild.nodeValue;
    
_loc10 mensajes_xml.firstChild.childNodes[7].firstChild.nodeValue;
    
_loc11 mensajes_xml.firstChild.childNodes[8].firstChild.nodeValue;
    
_loc9 mensajes_xml.firstChild.childNodes[9].firstChild.nodeValue;
    
_root.usuario1_txt.htmlText _root.usuario1_txt.htmlText _loc3;
    
_root.mensaje1_txt.htmlText _root.mensaje1_txt.htmlText _loc2;
    
_root.usuario2_txt.htmlText _root.usuario2_txt.htmlText _loc4;
    
_root.mensaje2_txt.htmlText _root.mensaje2_txt.htmlText _loc6;
    
_root.usuario3_txt.htmlText _root.usuario3_txt.htmlText _loc7;
    
_root.mensaje3_txt.htmlText _root.mensaje3_txt.htmlText _loc5;
    
_root.usuario4_txt.htmlText _root.usuario4_txt.htmlText _loc8;
    
_root.mensaje4_txt.htmlText _root.mensaje4_txt.htmlText _loc10;
    
_root.usuario5_txt.htmlText _root.usuario5_txt.htmlText _loc11;
    
_root.mensaje5_txt.htmlText _root.mensaje5_txt.htmlText _loc9;
// End of the function
System.useCodepage true;
var 
indice;
var 
mensajes_xml;
indice 0;
mensajes_xml = new XML();
mensajes_xml.ignoreWhite true;
mensajes_xml.load("mensajes.xml?nocache=" Math.random());
mensajes_xml.onLoad = function ()
{
    
cargarDatos(indice);
}; 

Este codigo hace que por medio de un archivo FLASH los vaya mostrando.


Tengo otro mas donde este genera el archivo XML para que sea interpretado por el FLASH

Código PHP:
<?php
function creaXML
/*Seleccionamos los datos de la tabla correspondiente*/ 

$result=mysql_query("SELECT id, nombre, comentarios FROM miTabla"); 

/*la variable $fp guardará el identificador del fichero con el que estamos trabajando. El fichero mensajes.xml lo creará en la misma ruta donde se ejecute el script de php.*/ 

if(!$fp=fopen("mensajes.xml","w+")) echo "No se ha podido abrir el fichero"
else 

    
/*Escribo la cabecera del xml 
    Véase que \r (retorno de carro) en octal es 015 y \n (nueva linea) en octal es 012*/ 

    
fwrite($fp,"<?xml version="1.0" encoding=\"ISO-8859-1\"?>\015\012")) 
    while(
$row=mysql_fetch_array($result)) 
    { 
        
/*estructura del nodo*/ 

        
fwrite($fp,"<mensajes>\015\012 
                                <id>"
.$row[id]."</id>\015\012 
                                <nombre>"
.$row[nombre]."</nombre>\015\012 
                                <mensaje1>"
.$row[comentarios]."</mensaje1>\015\012 
                          </mensajes>"
); 
    } 
    if(!
fclose($fp)) echo "No se ha podido cerrar el fichero"
}
?>

He ahi el problema no se como generar para que en el archivo XML me cree un archivo de tipo como el siguiente.

Código PHP:
<?xml version="1.0" encoding="iso-8859-1"?>
<mensajes>
<mensaje1>BIENVENIDOS AL CENTRO DE MENSAJES</mensaje1>
<mensaje2>BIENVENIDOS AL CENTRO DE MENSAJES</mensaje2>
</mensajes>

El problema es que no se como hacer para que me cree automaticamente en el XML mensaje1, mensaje2, mensaje3.


Si alguien me puede ayudar se los voy agradecer muchisimo.

Muchas Gracias!
  #2 (permalink)  
Antiguo 25/04/2010, 02:54
Avatar de abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 14 años, 11 meses
Puntos: 1517
Respuesta: Sistema de Comentarios PHP Mysql XML

No necesitas crear, como tal un archivo XML, solo debes con PHP mostrar la información. Creas un archivo de PHP, que se conecte a la base de datos y los datos los muestras en formato XML.
Código PHP:
Ver original
  1. <?php header ('Content-Type: text/xml'); ?>
  2. <?xml version="1.0"?>
  3. <mensajes>
  4. <mensaje1>BIENVENIDOS AL CENTRO DE MENSAJES</mensaje1>
  5. <mensaje2>BIENVENIDOS AL CENTRO DE MENSAJES</mensaje2>
  6. </mensajes>
__________________
Verifica antes de preguntar.
Los verdaderos amigos se hieren con la verdad, para no perderlos con la mentira. - Eugenio Maria de Hostos

Etiquetas: comentarios, mysql, xml, sitemap
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 08:32.