$20 reward for Helping with a Small PHP Issue!

Discussion in 'Programming' started by Rated, Apr 30, 2007.

  1. #1
    Hi all,

    I have a small script publishing RSS on my site, and was wondering if someone would be able to quickly edit it to display only 5 lines of news, rather than displaying all the news in the feed.

    Also, edit it so it only displays xxx characters then puts in "..." at the end. something like: .substr(,0,150)

    Heres the script:
    <?php
    $insideitem = false;
    $tag = "";
    $title = "";
    $description = "";
    $link = "";
    function startElement($parser, $name, $attrs) {
     global $insideitem, $tag, $title, $description, $link;
     if ($insideitem) {
      $tag = $name;
     } elseif ($name == "ITEM") {
      $insideitem = true;
     }
    }
    function endElement($parser, $name) {
     global $insideitem, $tag, $title, $description, $link;
     if ($name == "ITEM") {
      printf("<div class=\"cell-white\" onmouseover=\"this.className='cell-grey';\" onmouseout=\"this.className='cell-white';\" style=\"padding:5px; border-right: 1px solid #333333; border-left: 1px solid #333333; border-bottom: 1px solid #333333; \"><a style=\"font-weight:normal;\" href='%s'>%s</a></div>
      ",
      trim($link),htmlspecialchars(trim($title)));
      $title = "";
      $description = "";
      $link = "";
      $insideitem = false;
    		
     }
    }
    function characterData($parser, $data) {
     global $insideitem, $tag, $title, $description, $link;
     if ($insideitem) {
     switch ($tag) {
      case "TITLE":
      $title .= $data;
      break;
      case "LINK":
      $link .= $data;
      break;
     }
     }
    }
    $xml_parser = xml_parser_create();
    xml_set_element_handler($xml_parser, "startElement", "endElement");
    xml_set_character_data_handler($xml_parser, "characterData");
    $fp = fopen("http://www.nintendo.com/rss.xml","r")
     or die("Error reading RSS data.");
    while ($data = fread($fp, 4096))
     xml_parse($xml_parser, $data, feof($fp))
      or die(sprintf("XML error: %s at line %d",
       xml_error_string(xml_get_error_code($xml_parser)),  
       xml_get_current_line_number($xml_parser)));
    fclose($fp);
    xml_parser_free($xml_parser);
    ?>
    PHP:
    Payment by paypal :)

    Thanks!
     
    Rated, Apr 30, 2007 IP
  2. Rated

    Rated Active Member

    Messages:
    236
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    73
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #2
    Update: Someones taken on the job, thanks alot for the quick responses :)
     
    Rated, Apr 30, 2007 IP
  3. coderbari

    coderbari Well-Known Member

    Messages:
    3,168
    Likes Received:
    193
    Best Answers:
    0
    Trophy Points:
    135
    As Seller:
    100% - 0
    As Buyer:
    100% - 0
    #3
    if you need any PHP coder in future.plz contact me.i work for really cheap rate.i prefer to work for small scripts that you can add to your sites.
     
    coderbari, May 14, 2007 IP