How do I create a completely simple, static, RSS feed using PHP?
Why this will not work:
& lt ;? XML version = "1.0"? & Gt; & Lt; RSS version = \ "2.0 \" & gt; & Lt; Channel & gt; & Lt ;? Php echo " Channel title goes here title>"; ? & Gt; & Lt; Description & gt; Details about how items are related here & lt; / Description & gt; & Lt; Link & gt; Http: //www.directoryoflinksgohere< / Link & gt; & Lt; Items & gt; & Lt; Title & gt; The Title Go Year & lt; / Title & gt; & Lt; Details & gt; Details goes here & lt; / Description & gt; & Lt; Link & gt; Http: //www.linkgoeshere.com< / Link & gt; & Lt; / Item & gt; & Lt; Items & gt; & Lt; Title & gt; Another title is Goes here & lt; / Title & gt; & Lt; Details & gt; Another description goes here & lt; / Description & gt; & Lt; Link & gt; Http: //www.anotherlinkgoeshere.com< / Link & gt; & Lt; / Item & gt; & Lt; / Channel & gt; & Lt; / Rss & gt; Code> pre> I'll definitely need to update it with mysql automatically, but right now I need to know how hex how I use php in conjunction with RSS also can. P>
This is actually due to downloading an RSS file instead of displaying: p>
Php echo " & lt; Description & gt; Details from here & lt Goes to / description & gt; & lt; link & gt; http: //www.linkgoeshere< / link and gt; item> gt; & gt; item & gt; & lt; title & Another top A goes from here title> Another description goes here description> link & gt; http: // www. Anotherlinkgoeshere.com & lt; / link & gt; & lt; / items & gt; & lt; / channel & gt; & lt; / rss & gt; "; ? & Gt; Code> pre> Update: p>
This will output the RSS almost correctly. The value of variables is not written, but rather the name of the variable, instead of typing "yes", "$ toast" will be written instead. P>
& lt ;? Php $ counter = 0; $ Thor = mysqli_connect ("localhost", "username", "password", "database"); If (mysqli_connect_errno ($ con)) {echo "failed to connect to MySQL:". Mysqli_connect_error (); } $ Sql = mysqli_query ($ con, "people name select"); While ($ row = mysqli_fortch_array ($ sql)) {$ test [$ counter] = $ line ['name']; $ Counter ++; } $ Toast = "Yes"; Echo "header (\" content-type: application / RSS + xml; charset = ISO-885 9 -1 \ ") & lt ;? xml version = \" 1.0 \ "encoding = \" ISO-885 9 -1 \ "? & Gt; RSS version =" 2.0 "& gt; & lt; Channel & gt; & lt; title & gt; Channel title goes from here & lt; / title & gt; & lt ; Description & gt; $ test [0] & lt; / description & gt; & lt; link & gt; http: // www.directoryoflinksgohere & lt; / link & gt; & lt; items & gt; & lt; Title & gt; Title goes from here title> $ Toast description> gt; link & gt; http: //www.linkgoeshere. & Lt; Com & lt; / link & gt; & lt; / item & gt; & lt; items & Gt; & lt; Title & gt; Another title goes here & lt; / title & gt; & lt; Description & gt; Another description goes here & lt; / description & gt; & lt; link & gt; ; Http: //www.anotherlinkgoeshere&&bb/link"> gt; & gt; & gt; & lt; / channel & gt; & lt; / rss & gt; "; ? & Gt; Code> pre> div>
Add an .htaccess file with the following: p>
< Code> RewriteRule ^ sitemaps.xml $ /sitemap.php RewriteEngine current [L] code> pre> Create sitemap.php with the code you had p>
Full Strong > P> div> html>
No comments:
Post a Comment