Thursday, December 23 2004 @ 05:19 PM EST
Contributed by: anonymous
Views: 2,038
I've created a Links Block. I've used a number of different types of blogs in the past and all of them have had built in functionality to add links to your mainpage.. geeklog doesn't have that for some reason, so here is a block that adds that functionality. I don't know PHP or MySQL but I managed to get it all working perfectly for me, but you may want to go over my code before using it yourself..
--------------
function phpblock_LinksPage()
{
global $_TABLES, $_CONF, $LANG10;
$result = DB_query("SELECT DISTINCT category from {$_TABLES['links']} WHERE category > '' ORDER BY category DESC");
$nrows = DB_numRows($result);
if ($nrows > 0 )
{
for ($i = 1; $i <= $nrows; $i++)
{
$A = DB_fetchArray($result);
$cat = addslashes ($A['category']);
$result1 = DB_query ("SELECT count(*) AS count FROM {$_TABLES['links']} WHERE category = '{$cat}'");
$D = DB_fetchArray($result1);
$retval .='<b><u>' . $A['category'] . '</u></b><br>';
$titles = DB_query("select DISTINCT title,url,hits,lid from {$_TABLES['links']} WHERE category = '{$cat}' ORDER by title");
$ntitles= DB_numRows($titles);
if ($ntitles > 0)
{
for ($j = 1; $j <= $ntitles; $j++)
{
$B = DB_fetchArray($titles);
$title = addslashes ($B['title']);
$url = addslashes ($B['url']);
$retval .='<a href="/portal.php?what=link&item=' . $B['lid'] . '" target="_new">' . $B['title'] .'</a> <br>';
// $retval .= ''. $B['title'] . '<br>';
// $retval .= 'URL ='. $url . '<br>';
}
}
$retval .= '<br>';
}
} else {
$retval .= $LANG10[21];
}
return $retval;
}
--------