RSS script, only Product Title and Description

Hi guys, i was messing around with some php scripts that will create an RSS feed of your Product title and Description.



First create a PHP file “rss.php” add the following code into it and put it in your root dir (or create an rss directory and put it there). The CDATA commands helps the parsing of some characters in xml format so the feed gets validated and show up correctly.



```php





$dbhost = "localhost"; // almost always localhost.

$dbname = "databasename"; // Database Name, In our case, its news

$dbuser = "username"; // Database Username

$dbpass = "password"; // Databse Password



$connect = mysql_connect("$dbhost","$dbuser","$dbpass");// Connecting to Database

mysql_select_db($dbname) or die (mysql_error()); // Selecting Database

?>






Your Title Here
Link of you page
Description of your store


$sql = "SELECT * FROM cscart_product_descriptions";

$result = mysql_query($sql);

while($row = mysql_fetch_assoc($result)){

?>


]]>
http://www.yoursite.com/index.php?target=productsproduct_id

}
?>


```

Of course you can play with the rows and add short description instead of full. I was trying to grab data from the "cscart_products" table to list the price from the "list_price" row but i dont know how to do it. My knowledge is very limited, if someone else could make this happen it would be great!

If you like, for security reasons you can make an additional 'config.php' file to open the connection to the database and store it in a safer place than the root of your server and then insert an "include" command inside the 'rss.php' to call it.

Here in Greece RSS feeds for online stores are usefull in some ways especially in sites like the froogle but in Greek version but it's not free ;)

Feel free to make any suggestion to a n00b! :D

Hi predator,



Did you have any trouble with this script? Does it render the database with to the XML? I have tried a similar script from yours, the only major difference being the CDATA thing, I think.



You can read the post here.



Please let me know if you got it to work or not :wink:



Cheers!

Hey by chance can you do this to a single category?

tweaker, what you’ll have to to is follow one of these two scripts (the ones Predator proposed or the one I did) and add a statement to the SQL, something like



IF “category” equals “4”…



You still have to find the right SQL syntax and the right table in the database that has the categories.

I’m not all that SQL savvy. I found the $sql area but I don’t know what to change. The category ID is 63.



And when I try it without modifying anything except what needed to be changed I get the following error.





XML Parsing Error: not well-formed

Location: [url]http://users2.250host.com/~mattkars/store/rss.php[/url]

Line Number 5, Column 97: http://users2.250host.com/~mattkars/store/index.php?target=categories&category_id=63

------------------------------------------------------------------------------------------------^



Truth be told I have no idea what I’m even looking at.

What is the difference what we are discussing here and the RSS feed (default created) by Google for you in Google Base account.



Click the link in your Google Base account, under Your published items:



and on the page where it lists your item… or right side you get the RSS link


Post an item RSS

For me what I want to do is help distribute amongst my clientel community this one particular category of clearance products so that people who visit these websites see products change price. It’s a huge advantage for me because the majority of these people run a website using CMS.

What I would like to accomplish is to get a RSS feed listing all my products OR products for a single category so that customers get updated on what is latest in our store.



It looks like it’s really simple, but haven’t found a solution so far.

[quote name=‘Predator’]Hi guys, i was messing around with some php scripts that will create an RSS feed of your Product title and Description.



First create a PHP file “rss.php” add the following code into it and put it in your root dir (or create an rss directory and put it there). The CDATA commands helps the parsing of some characters in xml format so the feed gets validated and show up correctly.



```php





$dbhost = "localhost"; // almost always localhost.

$dbname = "databasename"; // Database Name, In our case, its news

$dbuser = "username"; // Database Username

$dbpass = "password"; // Databse Password



$connect = mysql_connect("$dbhost","$dbuser","$dbpass");// Connecting to Database

mysql_select_db($dbname) or die (mysql_error()); // Selecting Database

?>






Your Title Here
Link of you page
Description of your store


$sql = "SELECT * FROM cscart_product_descriptions";

$result = mysql_query($sql);

while($row = mysql_fetch_assoc($result)){

?>


]]>
http://www.yoursite.com/index.php?target=productsproduct_id

}
?>


```

Of course you can play with the rows and add short description instead of full. I was trying to grab data from the "cscart_products" table to list the price from the "list_price" row but i dont know how to do it. My knowledge is very limited, if someone else could make this happen it would be great!

If you like, for security reasons you can make an additional 'config.php' file to open the connection to the database and store it in a safer place than the root of your server and then insert an "include" command inside the 'rss.php' to call it.

Here in Greece RSS feeds for online stores are usefull in some ways especially in sites like the froogle but in Greek version but it's not free ;)

Feel free to make any suggestion to a n00b! :D[/QUOTE]

Hello i have this error

Warning: mysql_connect() [function.mysql-connect]: Acce...

Thanks.

zanimo check your database username and password

[quote name=‘JesseLeeStringer’]zanimo check your database username and password[/QUOTE]



oups… thanks it’s ok now.

[quote name=‘Predator’]Hi guys, i was messing around with some php scripts that will create an RSS feed of your Product title and Description.



First create a PHP file “rss.php” add the following code into it and put it in your root dir (or create an rss directory and put it there). The CDATA commands helps the parsing of some characters in xml format so the feed gets validated and show up correctly.



```php





$dbhost = "localhost"; // almost always localhost.

$dbname = "databasename"; // Database Name, In our case, its news

$dbuser = "username"; // Database Username

$dbpass = "password"; // Databse Password



$connect = mysql_connect("$dbhost","$dbuser","$dbpass");// Connecting to Database

mysql_select_db($dbname) or die (mysql_error()); // Selecting Database

?>






Your Title Here
Link of you page
Description of your store


$sql = "SELECT * FROM cscart_product_descriptions";

$result = mysql_query($sql);

while($row = mysql_fetch_assoc($result)){

?>


]]>
http://www.yoursite.com/index.php?target=productsproduct_id

}
?>


```

Of course you can play with the rows and add short description instead of full. I was trying to grab data from the "cscart_products" table to list the price from the "list_price" row but i dont know how to do it. My knowledge is very limited, if someone else could make this happen it would be great!

If you like, for security reasons you can make an additional 'config.php' file to open the connection to the database and store it in a safer place than the root of your server and then insert an "include" command inside the 'rss.php' to call it.

Here in Greece RSS feeds for online stores are usefull in some ways especially in sites like the froogle but in Greek version but it's not free ;)

Feel free to make any suggestion to a n00b! :D[/QUOTE]

Can you change the code to read the site news instead of products or catigories?

After much experimenting and reading posts here and several other places I’ve come up with a way to build an RSS feed of our site’s News articles. Thanks to Ryan Barr for the basic code solution!



Please note that due to my lack of knowledge with multiple sql queries, there is no ITEM DATE attached to each item as cs-cart decided to store that in a different table. Anybody know how to get that info and pull it in?



First of all, make a folder in your site root called “rss” or “feed” or whatever you want. Then place this PHP script inside named as “index.php” and edit the necessary areas (dbuser, dbpass, dbname, dbserver (localhost, perhaps) and the title, link, description and copyright. Save the file and test it.

If this works for you, please enjoy!


```php


xml version="1.0" encoding="iso-8859-1"";?>




Your Site Title Here
Your Site News Link Here
Your Description Here
Your Copyright Here


$query = 'SELECT * FROM `cscart_news_descriptions` ORDER BY `cscart_news_descriptions`.`news_id` DESC LIMIT 0,10';
$results = $db->query($query);
$number = $results->num_rows;

for ($i = 1; $i <= $number; $i++) {

$row = $results->fetch_assoc();

$title = $row['news'];
$description = $row['description'];
$link = $row['news_id'];
?>



]]>
http://www.viewville.com/index.php?target=news#
http://www.viewville.com/index.php?target=news#


}
?>




$db->close();
?> ```

[quote name=‘jeremyw’]After much experimenting and reading posts here and several other places I’ve come up with a way to build an RSS feed of our site’s News articles. Thanks to Ryan Barr for the basic code solution!

[/QUOTE]



I have installed the feed and it works great! Thanks for the post! We were getting ready to start posting more news and use it to update folks. This is a great way to be able to do it.



Any idea what permissions I am supposed to have the file as? Right now I saved it with ‘644’.

Awesome work. I got it installed on one of my client’s site and it works perfectly.



I did have problems getting it to work on my cscartskins site though…not sure what the problem is.

Hey Everyone…



I’m trying to get the Products RSS feed going…



It appears to almost work - 2 products show up in the feed, but then I get the following error:



This page contains the following errors:



error on line 29 at column 43: xmlParseEntityRef: no name

Below is a rendering of the page up to the first error.



Any thoughts? Thank you!