WEB Need help with this PHP code for an RSS feed.

Discussion in 'OT Technology' started by Oh its me 20, Oct 27, 2007.

  1. Oh its me 20

    Oh its me 20 New Member

    Joined:
    Sep 11, 2007
    Messages:
    1,042
    Likes Received:
    0
    I have a php code for an RSS feed. However, I want to add a bullet next to each title, however I don't know how to go about doing it. Any suggestions?

    Code:
    [FONT=Courier New][COLOR=#0000bb]<?php[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#0000bb]$insideitem [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]false[/COLOR][/FONT][FONT=Courier New][COLOR=#007700];[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#0000bb]$tag [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#dd0000]""[/COLOR][/FONT][FONT=Courier New][COLOR=#007700];[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#0000bb]$title [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#dd0000]""[/COLOR][/FONT][FONT=Courier New][COLOR=#007700];[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#0000bb]$description [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#dd0000]""[/COLOR][/FONT][FONT=Courier New][COLOR=#007700];[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#0000bb]$link [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#dd0000]""[/COLOR][/FONT][FONT=Courier New][COLOR=#007700];[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#007700]function [/COLOR][COLOR=#0000bb]startElement[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$parser[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]$name[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]$attrs[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]) {[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#007700]global [/COLOR][COLOR=#0000bb]$insideitem[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]$tag[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]$title[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]$description[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]$link[/COLOR][/FONT][FONT=Courier New][COLOR=#007700];[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#007700]if ([/COLOR][COLOR=#0000bb]$insideitem[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]) {[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#0000bb]$tag [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]$name[/COLOR][/FONT][FONT=Courier New][COLOR=#007700];[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#007700]} elseif ([/COLOR][COLOR=#0000bb]$name [/COLOR][COLOR=#007700]== [/COLOR][COLOR=#dd0000]"ITEM"[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]) {[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#0000bb]$insideitem [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]true[/COLOR][/FONT][FONT=Courier New][COLOR=#007700];[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#007700]}[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#007700]}[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#007700]function [/COLOR][COLOR=#0000bb]endElement[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$parser[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]$name[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]) {[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#007700]global [/COLOR][COLOR=#0000bb]$insideitem[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]$tag[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]$title[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]$description[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]$link[/COLOR][/FONT][FONT=Courier New][COLOR=#007700];[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#007700]if ([/COLOR][COLOR=#0000bb]$name [/COLOR][COLOR=#007700]== [/COLOR][COLOR=#dd0000]"ITEM"[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]) {[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#0000bb]printf[/COLOR][COLOR=#007700]([/COLOR][COLOR=#dd0000]"<dt><b><a href='%s'>%s</a></b></dt>"[/COLOR][/FONT][FONT=Courier New][COLOR=#007700],[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#0000bb]trim[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$link[/COLOR][COLOR=#007700]),[/COLOR][COLOR=#0000bb]htmlspecialchars[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]trim[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$title[/COLOR][/FONT][FONT=Courier New][COLOR=#007700])));[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#0000bb]printf[/COLOR][COLOR=#007700]([/COLOR][COLOR=#dd0000]"<dt>%s</dt><br><br>"[/COLOR][COLOR=#007700],[/COLOR][COLOR=#0000bb]htmlspecialchars[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]trim[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$description[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]))) ;[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#0000bb]$title [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#dd0000]""[/COLOR][/FONT][FONT=Courier New][COLOR=#007700];[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#0000bb]$description [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#dd0000]""[/COLOR][/FONT][FONT=Courier New][COLOR=#007700];[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#0000bb]$link [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#dd0000]""[/COLOR][/FONT][FONT=Courier New][COLOR=#007700];[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#0000bb]$insideitem [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]false[/COLOR][/FONT][FONT=Courier New][COLOR=#007700];[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#007700]}[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#007700]}[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#007700]function [/COLOR][COLOR=#0000bb]characterData[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$parser[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]$data[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]) {[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#007700]global [/COLOR][COLOR=#0000bb]$insideitem[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]$tag[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]$title[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]$description[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]$link[/COLOR][/FONT][FONT=Courier New][COLOR=#007700];[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#007700]if ([/COLOR][COLOR=#0000bb]$insideitem[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]) {[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#007700]switch ([/COLOR][COLOR=#0000bb]$tag[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]) {[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#007700]case [/COLOR][COLOR=#dd0000]"TITLE"[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]:[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#0000bb]$title [/COLOR][COLOR=#007700].= [/COLOR][COLOR=#0000bb]$data[/COLOR][/FONT][FONT=Courier New][COLOR=#007700];[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#007700]break;[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#007700]case [/COLOR][COLOR=#dd0000]"DESCRIPTION"[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]:[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#0000bb]$description [/COLOR][COLOR=#007700].= [/COLOR][COLOR=#0000bb]$data[/COLOR][/FONT][FONT=Courier New][COLOR=#007700];[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#007700]break;[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#007700]case [/COLOR][COLOR=#dd0000]"LINK"[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]:[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#0000bb]$link [/COLOR][COLOR=#007700].= [/COLOR][COLOR=#0000bb]$data[/COLOR][/FONT][FONT=Courier New][COLOR=#007700];[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#007700]break;[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#007700]}[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#007700]}[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#007700]}[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#0000bb]$xml_parser [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]xml_parser_create[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]();[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#0000bb]xml_set_element_handler[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$xml_parser[/COLOR][COLOR=#007700], [/COLOR][COLOR=#dd0000]"startElement"[/COLOR][COLOR=#007700], [/COLOR][COLOR=#dd0000]"endElement"[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]);[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#0000bb]xml_set_character_data_handler[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$xml_parser[/COLOR][COLOR=#007700], [/COLOR][COLOR=#dd0000]"characterData"[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]);[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#0000bb]$fp [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]fopen[/COLOR][COLOR=#007700]([/COLOR][COLOR=#dd0000]"http://michaelthompson.org/news/goo-world.xml"[/COLOR][COLOR=#007700],[/COLOR][COLOR=#dd0000]"r"[/COLOR][/FONT][FONT=Courier New][COLOR=#007700])[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#007700]or die([/COLOR][COLOR=#dd0000]"Error reading RSS data."[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]);[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#007700]while ([/COLOR][COLOR=#0000bb]$data [/COLOR][COLOR=#007700]= [/COLOR][COLOR=#0000bb]fread[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$fp[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]4096[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]))[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#0000bb]xml_parse[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$xml_parser[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]$data[/COLOR][COLOR=#007700], [/COLOR][COLOR=#0000bb]feof[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$fp[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]))[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#007700]or die([/COLOR][COLOR=#0000bb]sprintf[/COLOR][COLOR=#007700]([/COLOR][COLOR=#dd0000]"XML error: %s at line %d"[/COLOR][/FONT][FONT=Courier New][COLOR=#007700],[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#0000bb]xml_error_string[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]xml_get_error_code[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$xml_parser[/COLOR][/FONT][FONT=Courier New][COLOR=#007700])), [/COLOR][/FONT]
    [FONT=Courier New][COLOR=#0000bb]xml_get_current_line_number[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$xml_parser[/COLOR][/FONT][FONT=Courier New][COLOR=#007700])));[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#0000bb]fclose[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$fp[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]);[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#0000bb]xml_parser_free[/COLOR][COLOR=#007700]([/COLOR][COLOR=#0000bb]$xml_parser[/COLOR][/FONT][FONT=Courier New][COLOR=#007700]);[/COLOR][/FONT]
    [FONT=Courier New][COLOR=#0000bb]?>[/COLOR][/FONT]
     
  2. Gromer

    Gromer Strange things are afoot at the Circle-K!

    Joined:
    Dec 30, 2001
    Messages:
    72,573
    Likes Received:
    0
    Location:
    Salt Lake City, UT
    Integrate this into your code:

    Code:
    <ul>
         <li>Insert feed title/link/headline/whatever here</li>
    </ul>
    
     
  3. kingtoad

    kingtoad OT Supporter

    Joined:
    Sep 2, 2003
    Messages:
    55,918
    Likes Received:
    10
    Location:
    Los Angeles
    You're using definition lists. You need to use unordered lists, just like Gromer pointed out.
     
  4. Oh its me 20

    Oh its me 20 New Member

    Joined:
    Sep 11, 2007
    Messages:
    1,042
    Likes Received:
    0
    Where would I implement that? I know the <ul> is the command for the list, and the <li> is what defines the bullet, but I don't know how to go about inserting it into the code.
     
  5. FLY-FAST

    FLY-FAST OT Supporter

    Joined:
    Sep 30, 2003
    Messages:
    8,713
    Likes Received:
    3
    Location:
    boston, MA
    most certainly
     
  6. kingtoad

    kingtoad OT Supporter

    Joined:
    Sep 2, 2003
    Messages:
    55,918
    Likes Received:
    10
    Location:
    Los Angeles
    You should use this. Not that custom bullshit you have going on.

    http://magpierss.sourceforge.net/
     
  7. Oh its me 20

    Oh its me 20 New Member

    Joined:
    Sep 11, 2007
    Messages:
    1,042
    Likes Received:
    0
    Do you happen to know of an install?

    The installation link on that page is dead.

    Also, what is the benefit of using magpie vs the code i have now with a <li>?
     
  8. kingtoad

    kingtoad OT Supporter

    Joined:
    Sep 2, 2003
    Messages:
    55,918
    Likes Received:
    10
    Location:
    Los Angeles
    Read the "readme" files after downloading MagPie RSS.

    The benefit of using magpie vs. the code you have is that you can output your RSS feeds however you please. Whereas the code you're using seems to have embedded definition lists with your feeds.
     

Share This Page