Connecting Tech Pros Worldwide Help | Site Map

RSS with PHP and MySQL

  #1  
Old March 5th, 2006, 04:15 PM
Laeronai
Guest
 
Posts: n/a
Say that I have a table in my MySQL database that holds all the RSS
information for my blog posts. I have link, title, and description.
could I make an RSS feed with PHP code in it, or would that not just be
possible? I was thinking along the lines of:

while ($rssinfo = mysql_fetch_array($query, mysql_assoc)) {
echo '<item><title>' . $rssinfo['title'] . '</title><description>' .
$rssinfo['description'] . '</description><link>' . $rssinfo['link'] .
'</link</item>';
}

I would put this in feed.xml or something like that, which would hold
all the feed information. Would this code work, or would I have to use
some other method?

  #2  
Old March 5th, 2006, 10:45 PM
Janwillem Borleffs
Guest
 
Posts: n/a

re: RSS with PHP and MySQL


Laeronai wrote:[color=blue]
> I would put this in feed.xml or something like that, which would hold
> all the feed information. Would this code work, or would I have to use
> some other method?
>[/color]

As a rough outline, it will work, but keep the following in mind:

* Generating a static file, which is refreshed once in a while might be a
good idea;
* Follow the specifications (http://web.resource.org/rss/1.0/spec).

And, on a side note:

* PHP constants are case-sensitive (it's not mysql_assoc, but MYSQL_ASSOC).


JW



  #3  
Old March 5th, 2006, 11:05 PM
Gale
Guest
 
Posts: n/a

re: RSS with PHP and MySQL


Laeronai wrote:[color=blue]
> Say that I have a table in my MySQL database that holds all the RSS
> information for my blog posts. I have link, title, and description.
> could I make an RSS feed with PHP code in it, or would that not just be
> possible? I was thinking along the lines of:
>
> while ($rssinfo = mysql_fetch_array($query, mysql_assoc)) {
> echo '<item><title>' . $rssinfo['title'] . '</title><description>' .
> $rssinfo['description'] . '</description><link>' . $rssinfo['link'] .
> '</link</item>';
> }
>
> I would put this in feed.xml or something like that, which would hold
> all the feed information. Would this code work, or would I have to use
> some other method?
>[/color]

http://codewalkers.com/seecode/607.html
  #4  
Old March 6th, 2006, 04:05 AM
Laeronai
Guest
 
Posts: n/a

re: RSS with PHP and MySQL


I know it's uppercase, but the "c" key on my keyboard broke. I copied
and pasted a lowercase "c" just for ease of posting, but when I code I
copy and paste an uppercase "c." I need to get it fixed. Laptop
keyboards are a pain.

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is PhP/mySQL right for this project? Susan Baker answers 15 December 24th, 2005 03:35 PM
RSS feeds with PHP and MySQL? Zenbug answers 4 September 7th, 2005 05:35 AM
Using XML with PHP Ian N answers 0 August 23rd, 2005 01:15 PM
PHP sessions starting to fail jamie howard answers 13 July 17th, 2005 01:44 PM