Partage
  • Partager sur Facebook
  • Partager sur Twitter

flux rss php xml

Creation fichier xml auto

Sujet résolu
    13 mai 2006 à 17:56:34

    Salut à toutes et à tous !

    petit probléme, j'ai un fichier maj-rss.php qui me génére un fichier fluxrss.xml devant afficher les dix derniers articles de ma base. Probléme, il me génére bien le fichier avec les infos de base, mais aucun article.

    Voici le code:
    <?php
    $xml = '<?xml version="1.0" encoding="iso-8859-1"?><rss version="2.0">';
    $xml .= '<channel>';
    $xml .= '<title>Militaria.fr</title>';
    $xml .= '<link>http://www.militaria.fr</link>';
    $xml .= '<description>Achat et vente de militaria de collection </description>';
    $xml .= '<copyright>© Militaria.fr</copyright>';
    $xml .= '<language>fr</language>';
    $xml .= '<image>';
    $xml .= '       <title>Militaria.fr</title>';
    $xml .= '       <url>http://www.militaria.fr/rss/rss.gif</url>';
    $xml .= '       <link>http://www.Militaria.fr</link>';
    $xml .= '</image>';
    $jourdui= date("D, d M Y H:i:s +0100");
    $xml .= '<pubdate>'.$jourdui.'</pubdate>';

    require ('connect.php');

    $res=mysql_query("select * from  kpro_shop_articles order by date desc limit 0, 10");

    // extraction des 10 dernièrs articles
    while($lig=mysql_fetch_array($res)){   
                    $title=$lig[tag];
                    $adresse=$lig[adresse];
                    $descr=$lig[descr];
                    $madate=$lig[date];
                    $datephp=date("D, d M Y H:i:s +0100", strtotime($madate));

                $xml .= '<item>';
                $xml .= '<title>'.$title.'</title>';
                $xml .= '<link>'.$adresse.'</link>';
                            $xml .= '<pubDate>'.$datephp.'</pubDate>';
                $xml .= '<description>'.$descr.'</description>';
                $xml .= '</item>'
            }

    $xml .= '</channel>';
    $xml .= '</rss>';
           
    $fp = fopen("fluxrss.xml", 'w+');
    fputs($fp, $xml);
    fclose($fp);
           
    echo 'Export XML effectue !<br><a href="fluxrss.xml">Voir le fichier</a>';
    ?>


    En live , cela donne :

    http://www.militaria.fr/rss/maj-rss.php

    La, je capte plus ! :-°

    Merci de votre aide :)

    • Partager sur Facebook
    • Partager sur Twitter

    flux rss php xml

    × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
    × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
    • Editeur
    • Markdown