Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Output feedwordpress database for use in Planet (See related posts)

You'll need to change the initial settings as I didn't bother to read them from the Wordpress config file. You may also need to change the table name (wp_links) in the sql query.

<?php
$username = "myuser";
$password = "P455w0rd";
$database = "db_name";
$hostname = "127.0.0.1";

$query = "SELECT link_name, link_rss FROM wp_links WHERE link_category=2";

mysql_connect($hostname, $username,$password);
@mysql_select_db($database) or die("Unable to select database");
$result = mysql_query($query);
$num = mysql_numrows($result);
mysql_close();

$i=0;
while($i < $num) {
        $rss = mysql_result($result,$i,"link_rss");
        $name = mysql_result($result,$i,"link_name");

        echo "[".$rss."]\r\n";
        echo "name = ".$name."\r\n";
        $i++;
}
?>


You need to create an account or log in to post comments to this site.


Click here to browse all 5140 code snippets

Related Posts