• The website is https://www.svm2.net/v2/
    We had a guy help us build the site. He created a feed parser to get blog post titles to appear on the home page of the website, but the php code is only producing titles and not links to the actual page. The guy backed out and I am left with a broken code I don’t know how to fix. Can you help? Here is the code:

    <?php
    $rss = new DOMDocument();
    $rss->load('https://svm2.net/abandonedtimes/feed');
    $feed = array();
    foreach ($rss->getElementsByTagName('item') as $node) {
    $item = array (
    'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
    'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
    'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
    'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
    );
    array_push($feed, $item);
    }
    $limit = 3;
    
    echo '<ul>';
    for($x=0;$x<$limit;$x++) {
    	$title = str_replace(' & ', ' & ', $feed[$x]['title']);
    	$link = ($feed[$x]['link']);
    	$description = $feed[$x]['desc'];
    	$date = date('l F d, Y', strtotime($feed[$x]['date']));
    	//echo '<p><strong><a href="'.$link.'" title="'.$title.'">'.$title.'</a></strong><br />';
    	//echo '<small><em>Posted on '.$date.'</em></small></p>';
    	//echo '<p>'.$description.'</p>';
    	echo '<li><a href="$link">'.$title.'</a></li>';
    }
    echo '<li><a href="https://svm2.net/abandonedtimes/">READ ALL </a></li>';
    echo '</ul>';
    ?>

Viewing 1 replies (of 1 total)
  • Nimesh

    (@nimeshrathod1)

    @svm2,
    Replace this line,
    echo '<li><a href="$link">'.$title.'</a></li>';
    with this,
    echo '<li><a href="'.$link.'">'.$title.'</a></li>';
    in for loop.

Viewing 1 replies (of 1 total)
  • The topic ‘php problem’ is closed to new replies.