RSS with PHP and MySQL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Laeronai

    RSS with PHP and MySQL

    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_arr ay($query, mysql_assoc)) {
    echo '<item><title> ' . $rssinfo['title'] . '</title><descript ion>' .
    $rssinfo['description'] . '</description><li nk>' . $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?

  • Janwillem Borleffs

    #2
    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



    Comment

    • Gale

      #3
      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_arr ay($query, mysql_assoc)) {
      > echo '<item><title> ' . $rssinfo['title'] . '</title><descript ion>' .
      > $rssinfo['description'] . '</description><li nk>' . $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]


      Comment

      • Laeronai

        #4
        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.

        Comment

        Working...