Results 1 to 4 of 4

Thread: RSS w/ PHP

  1. #1
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default RSS w/ PHP

    Hey guys...

    So, I'm trying to create a RSS feed (actually, multiple RSS feeds) through PHP & MySQL. This works fine when there is only one table to query.

    However, on my homepage, I'm using content from several tables. So, how would I adapt the following scripts to query several MySQL tables (7 to be exact)...

    PHP Code:
    <?  
    include("feedcreator.class.php"); 

    $rss = new UniversalFeedCreator(); 
    $rss->useCached(); 
    $rss->title "PHP news"
    $rss->description "daily news from the PHP scripting world"
    $rss->link "http://www.dailyphp.net/news"
    $rss->syndicationURL "http://www.dailyphp.net/".$PHP_SELF

    $image = new FeedImage(); 
    $image->title "dailyphp.net logo"
    $image->url "http://www.dailyphp.net/images/logo.gif"
    $image->link "http://www.dailyphp.net"
    $image->description "Feed provided by dailyphp.net. Click to visit."
    $rss->image $image

    // get your news items from somewhere, e.g. your database: 
    mysql_select_db($dbHost$dbUser$dbPass); 
    $res mysql_query("SELECT * FROM news ORDER BY newsdate DESC"); 
    while (
    $data mysql_fetch_object($res)) { 
        
    $item = new FeedItem(); 
        
    $item->title $data->title
        
    $item->link $data->url
        
    $item->description $data->short
        
    $item->date $data->newsdate
        
    $item->source "http://www.dailyphp.net"
        
    $item->author "John Doe"
         
        
    $rss->addItem($item); 


    $rss->saveFeed("RSS1.0""news/feed.xml"); 
    ?>

  2. #2
    Join Date
    Jan 2008
    Posts
    32
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    1) Could you explain why you're using multiple tables instead of just 1 to clarify?
    2) What's wrong with just copy/pasting the while loop and altering the query?

  3. #3
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Quote Originally Posted by Leafy View Post
    1) Could you explain why you're using multiple tables instead of just 1 to clarify?
    The website is a literary journal, seperated into seven different categories. When I was building the site, I made a seperate DB table for each category as there are several subcategories within each that need to be stored in the DB was well.

    The homepage pulls from each of these tables to show "featured" entries.


    Quote Originally Posted by Leafy View Post
    1) Could you explain why you're using multiple tables instead of just 1 to clarify?
    2) What's wrong with just copy/pasting the while loop and altering the query?
    I'm not sure...maybe nothing. But I'm sure what that entails.

  4. #4
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Got it, thanks!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •