1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

PHP XML Link Structure

Discussion in 'PHP' started by t0mb, Aug 9, 2010.

  1. #1
    I'm creating an RSS feed using MySQL and PHP. Have everything working except the link structure.

    $rssfeed .= '<link>' . <a href="http://url/path.php?ID=$ID">$Title</a> . '</link>';
    Code (markup):
    Can anyone provide a resource where I can learn to structure this correctly?
     
    t0mb, Aug 9, 2010 IP
  2. po_taka

    po_taka Peon

    Messages:
    14
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    $rssfeed .= '<link>' . htmlspecialchars('<a href=".......">...</a>') . '</link>';
     
    po_taka, Aug 9, 2010 IP
  3. t0mb

    t0mb Active Member

    Messages:
    1,116
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #3
    Hi po_taka,

    Thanks for that but I need to include the variable $ID in the link. Is this possible using htmlspecialchars?

    $rssfeed .= '<link>' . $ID . '</link>'; This works but goes to wrong destination

    $rssfeed .= '<link>' . (path)$ID . '</link>';
     
    t0mb, Aug 9, 2010 IP
  4. t0mb

    t0mb Active Member

    Messages:
    1,116
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    80
    #4
    To explain a little better...

    Here's what I have:

    $rssfeed .= '<title>' . $Title . '</title>';
    $rssfeed .= '<description>' . $Description . '</description>';
    $rssfeed .= '<link>' . $ID . '</link>';

    I'm trying to link <link> to URLs with this structure - http://www.url.com/View-This.php?ID=$ID

    Whereby $ID is inserted from the database.

    How would I include the relative path into the code below?

    $rssfeed .= '<link>' . $ID . '</link>';
     
    t0mb, Aug 9, 2010 IP
  5. Rainulf

    Rainulf Active Member

    Messages:
    373
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    85
    #5
    It doesn't work because you got the syntax wrong. Try this:
    
    $rssfeed .= "<link><a href=\"http://url/path.php?ID=$ID\">$Title</a></link>";
    
    PHP:
     
    Rainulf, Aug 9, 2010 IP
  6. HuggyEssex

    HuggyEssex Member

    Messages:
    297
    Likes Received:
    4
    Best Answers:
    2
    Trophy Points:
    45
    #6
    I've posted the fix for this in your services thread.
     
    HuggyEssex, Aug 9, 2010 IP