Rnews blogroll

I recently posted about my blogroll on the frontpage not being up to date. Well I fixed that. And from now on it should remain up to date, that is if the site has a news feed.

I mentioned I am using a webbased RSS aggregator called Rnews (view). Rnews uses a database to store the information extracted from the rss feeds. So basicly it wasn't that difficult to extract my blogroll, plus it's categorized!

<!--more-->

I changed the code a bit, so anyone using Rnews can create a blogroll.

<?php

// configuration //

$rnewsname = 'name'; //rnews username (same as login)


// database configuration //

$dbhost = 'localhost';
$dbusername = 'username';
$dbpassword = 'password';
$dbname = 'database';


// database connection //

mysql_connect($dbhost,$dbusername,$dbpassword) or die (mysql_error());
mysql_select_db($dbname) or die(mysql_error());


// get the links //

$table = $rnewsname . "_links";

$query_cat = mysql_query("SELECT DISTINCT category FROM $table ORDER BY category ASC");

while ($cat = mysql_fetch_array($query_cat)) {

      $cat = $cat[0];

        echo '<h4>' . $cat . '</h4>' . "\n";
        echo '<ul>' . "\n";

        $query_links = mysql_query("SELECT * FROM $table WHERE category = '$cat' ORDER BY name ASC");

  		  while ($row_links = mysql_fetch_array($query_links)) {

      			$site_name = $row_links['name'];
      			$link = $row_links['main_link'];
      			$image = $row_links['image_url'];
      			$id = $row_links['id'];



      			echo '<li><a href="' . $link . '" title="' . $site_name . '">' . $site_name . '</a></li>' . "\n";

        }

        echo '</ul>' . "\n";

}

?>

As you can see it's easy to use, just copy and past the code in a php document and fill out the required fields. The output is a list of the sites in the database using the <ul> tag.

20 april 2004

Bloggen, English, php, Programmeren, Web

back to top