So im trying to show my feeds from the file feed.php (its rss) on my frontpage index.php.. But its like it cant read my inputs 'item' 'title' etc from feed.php when i load it to the index.php.... however, there doesnt seem to be any trouble in feed.php itself
Index.php i have following code
$feed = simplexml_load_file('feed.php');
$counter = 0;
$amount = 5;
foreach($feed->channel->item as $item){
while ($counter<$amount) {
echo utf8_decode("<a href='{$item->link}'>{$item->title}</a><br>");
echo utf8_decode("<i>{$item->pubDate} </i><br>");
echo utf8_decode("{$item->description} <br><br>");
break;
}
$counter ++;
}
And this in feed.php
<rss version="2.0">
<channel>
<title>This is the title</title>
<link>http://www.someweirdurl.com</link>
<description>Just a testpage</description>
<?php
require_once 'dbconn.php';
$sql = "SELECT * FROM feeds";
$obj_result = $obj_con->query($sql);
while ($row = $obj_result->fetch_object()) {
?>
<item>
<title><?php echo $row->artikel_title; ?></title>
<link><?php echo $row->artikel_url; ?></link>
<description><?php echo $row->artikel_tekst; ?></description>
<author><?php echo $row->artikel_forfatter; ?></author>
<category><?php echo $row->artikel_kategori; ?></category>
<subDate>Fri, 05 Jul 2013 15:29:07 +0200</subDate>
</item>
<?php
}
?>
</channel>
</rss>
I tried to print it on index.php and it gives me outputs like
[author] => SimpleXMLElement Object
Its like they are empty.. While it get the subDate (as the only one)
[subDate] => Fri, 05 Jul 2013 15:29:07 +0200
Probably due to subDate is the only one i didnt take out from the database.. So what do i have to make different to make it work with data from my database..?