Hi there. I am looking for an easy way to update my RSS feed via a form. So at the end of the day I can enter a number into the form and it will update my feed dynamically. I need the bit of code that would grab the information from the mysql table and then format the php into a proper RSS code. Can anyone help out? Thanks!
Try this out: <?php // Database settings $dbhost = 'localhost'; // your host name, default is localhost $dbuser = 'username'; // your database username $dbpass = 'passwordhere'; // your database password $dbname = 'databasename'; // your database name mysql_connect($dbhost,$dbuser,$dbpass) or die ("I could not connect!"); // Select and connect to the database mysql_select_db($dbname) or die (mysql_error()); // Start the RSS Feed header('Content-type: text/xml'); // Must declare the content type echo '<?xml version=\'1.0\' encoding=\'UTF-8\'?>'; // Set RSS version. echo ' <rss version=\'2.0\'> '; // Start the XML. echo ' <channel> <title>Your Website</title> <description>Description of your website</description> <link>http://www.yourwebsite.com/</link>'; // Query database and select the last 10 entries. $data = mysql_query('SELECT * FROM table ORDER BY id DESC LIMIT 10'); while($row = mysql_fetch_array($data)) { echo ' <item> <link>http://www.yourwebsite.com/#'.$row['id'].'</link> <title>'.$row['title'].'</title> <description>'.$row['description'].'</description> </item>'; } // The "while" statement loops and grabs the //last 10 items as we stated in our $data query. // The <link> provides us with an anchor to the post //on the main page. It is using the post ID from the database. echo ' </channel> </rss>'; ?> Code (markup): This will grab the last ten items from your DB and format them into an RSS feed. That way when ever the script is called, your RSS feed updates. Hope this helps!