ok, then
Im still stuck on one problem,
heres my assignment
Your RSS feed is to display these fields:
Product Name
Product Line
Product Scale
Product Vendor
Product Description
Buy Price formatted in US dollars
The product name of each feed item, is to be a link to a product page. You may choose the format of the remaining item data.
I have most of it down, but looked at the available tags and made some guesses, is this ok?
<?php header('Content-Type: text/xml'); ?>
<?php echo '<?xml version="1.0" encoding="utf-8"?>'; ?>
<rss version='2.0'>
<channel>
<title><![CDATA[Assignment 9 - Newsfeed]]></title>
<link>http://teamluke.net/</link>
<webMaster>lurtnowski@gmail.com</webMaster>
<description><![CDATA[The trials & Tribulations of Luke Urtnowski as I complete this assignment.]]></description>
<language>en-us</language>
<image>
<title>Luke Urtnowski</title>
<url>http://php_class.teamluke.net/Assignment_9/images/luke.jpg</url>
<link>http://php_class.teamluke.net/Assignment_9/images/luke.jpg</link>
<description><![CDATA[The trials & Tribulations of Luke Urtnowski as I complete this assignment.]]></description>
</image>
<?php
require_once('db/conn.php');
try {
$stmt = $conn->prepare('SELECT productCode, productName, productLine, productDescription, productVendor, buyPrice FROM `products` WHERE productLine = "Trains" OR productLine = "Vintage Cars" ORDER BY timeStamp ASC LIMIT 10');
$stmt->execute();
if($stmt->rowCount()) {
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
echo '<item>';
echo ' <link>http://php_class.teamluke.net/Assignment_9/product.php?Code='.$row['productCode'].'>';
echo ' <title>' . $row['productName'] . '</title>';
echo ' </link>';
echo ' <category>' . $row['productLine'] . '</category>';
echo ' <source>' . $row['productVendor'] . '</source>';
echo ' <description><![CDATA[' . $row['productDescription'] . ']]></description>';
echo ' <Price>$' .number_format($row['buyPrice'], 2) . '</Price>';
echo '</item>';
}
}
} catch(PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
}
?>
</channel>
</rss>
I looked and couldn’t figure out if my code in the while loop makes sence.
Does it to you?
Maybe you’re thinking of HTML anchor tags?
Trying to sneak something in instead of using a namespace for you “custom” tags?
AFAIK <title> nested inside of <link> isn’t valid.
There’s nothing wrong with experimenting and trying to do things differently. That;s how progress is made.
But believe me, I do it quite often myself and the vast majority of times it results in FAIL.
If you don’t want to tackle namespaces quite yet, I suggest you comment out the custom tag lines of code for now and see if you can get it to be valid without them first before moving on.
Dang, didn’t know how the RSS worked
(attachment)
When I go to the page and open up the reader, all it shows are the and < link> elements of each of the 10 items. What is the purpose of the other available tags, and why use a namespace?