Welcome to Geeklog, Anonymous Sunday, December 22 2024 @ 02:35 am EST
Geeklog Forums
PHP links block
Status: offline
Euan
Forum User
Full Member
Registered: 04/22/02
Posts: 292
Here's a phpBlock to show the top links on the front page. I didn't find one of these anywhere else but I think I saw one somewhere once.
Add the following to your system/lib-custom.php file:
function phpblock_topLinks()
{
global $_TABLES, $_CONF, $LANG10;
$result = DB_query("SELECT lid,url,title,hits from WHERE hits > 0 ORDER BY hits desc LIMIT 10"
$nrows = DB_numRows($result);
if ($nrows > 0) {
for ($i = 0; $i < $nrows; $i++) {
$A = DB_fetchArray($result);
$retval .= '<a href="' . $_CONF['site_url'] . '/portal.php?url=' . $A['url'] . '&what=link&item=' . $A['lid'] . '">' . $A['title'] . '</a> (' . $A['hits'] . ')<br>';
}
} else {
$retval .= $LANG10[21];
}
return $retval;
}
Then create a phpBlock to call the function.
This is ripped from the stats.php file.
Cheers,
Euan.
-- Heather Engineering
-- No job too small
-- Heather Engineering
-- No job too small
20
18
Quote
Anonymous
Anonymous
Oops. Didn't notice that. Thanks! Euan.
21
21
Quote
Anonymous
Anonymous
Hopefully that will fix this error:
1064: You have an error in your SQL syntax near 'WHERE hits > 0 ORDER BY hits desc LIMIT 10' at line 1
1064: You have an error in your SQL syntax near 'WHERE hits > 0 ORDER BY hits desc LIMIT 10' at line 1
17
18
Quote
Status: offline
ScurvyDawg
Forum User
Full Member
Registered: 11/06/02
Posts: 523
I am getting this error in my error log
Tue May 18 20:20:53 2004 - 1064: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '> 0 ORDER BY hits desc LIMIT 10' at line 1. SQL in question: SELECT lid,url,title,hits from gl_linksWHERE hits > 0 ORDER BY hits desc LIMIT 10
This is the function I am using
function phpblock_topLinks()
{
global $_TABLES, $_CONF, $LANG10;
$retval .= "<p><table width="100%" border="0">n";
$retval .= "<tr><td><b>Site Name</b></td><td><b>Hits</b></td></tr>";
$result = DB_query("SELECT ID,SiteName,SiteURL,HitsOut from {$_TABLES['pllinks']} WHERE HitsOut > 0 ORDER BY HitsOut desc LIMIT 0, 10");
$nrows = DB_numRows($result);
if ($nrows > 0) {
for ($i = 0; $i < $nrows; $i++) {
$A = DB_fetchArray($result);
$retval .='<tr><td><a href="' . $_CONF['site_url'] . '/phplinks/out_frame.php?&ID=' . $A['ID'] . '">' . $A['SiteName'] . '';
$retval .='</a></td><td>' . $A['HitsOut'] . '</td></tr>';
}
} else {
$retval .="<tr><td align="center">";
$retval .= $LANG10[21];
$retval .="</td></tr>";
}
$retval .="</table><p>";
$retval .="<center>";
$retval .= '<a href="' . $_CONF['site_url'] . '/phplinks/index.php">More Links</a>';
$retval .="</center>";
return $retval;
}
Text Formatted Code
Tue May 18 20:20:53 2004 - 1064: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '> 0 ORDER BY hits desc LIMIT 10' at line 1. SQL in question: SELECT lid,url,title,hits from gl_linksWHERE hits > 0 ORDER BY hits desc LIMIT 10
This is the function I am using
Text Formatted Code
function phpblock_topLinks()
{
global $_TABLES, $_CONF, $LANG10;
$retval .= "<p><table width="100%" border="0">n";
$retval .= "<tr><td><b>Site Name</b></td><td><b>Hits</b></td></tr>";
$result = DB_query("SELECT ID,SiteName,SiteURL,HitsOut from {$_TABLES['pllinks']} WHERE HitsOut > 0 ORDER BY HitsOut desc LIMIT 0, 10");
$nrows = DB_numRows($result);
if ($nrows > 0) {
for ($i = 0; $i < $nrows; $i++) {
$A = DB_fetchArray($result);
$retval .='<tr><td><a href="' . $_CONF['site_url'] . '/phplinks/out_frame.php?&ID=' . $A['ID'] . '">' . $A['SiteName'] . '';
$retval .='</a></td><td>' . $A['HitsOut'] . '</td></tr>';
}
} else {
$retval .="<tr><td align="center">";
$retval .= $LANG10[21];
$retval .="</td></tr>";
}
$retval .="</table><p>";
$retval .="<center>";
$retval .= '<a href="' . $_CONF['site_url'] . '/phplinks/index.php">More Links</a>';
$retval .="</center>";
return $retval;
}
18
19
Quote
Status: offline
ScurvyDawg
Forum User
Full Member
Registered: 11/06/02
Posts: 523
OK I am sure I am being a blind fool but where within
function phpblock_topLinks()
{
global $_TABLES, $_CONF, $LANG10;
$retval .= "<p><table width="100%" border="0">n";
$retval .= "<tr><td><b>Site Name</b></td><td><b>Hits</b></td></tr>";
$result = DB_query("SELECT ID,SiteName,SiteURL,HitsOut from {$_TABLES['pllinks']} WHERE HitsOut > 0 ORDER BY HitsOut desc LIMIT 0, 10");
$nrows = DB_numRows($result);
if ($nrows > 0) {
for ($i = 0; $i < $nrows; $i++) {
$A = DB_fetchArray($result);
$retval .='<tr><td><a href="' . $_CONF['site_url'] . '/phplinks/out_frame.php?&ID=' . $A['ID'] . '">' . $A['SiteName'] . '';
$retval .='</a></td><td>' . $A['HitsOut'] . '</td></tr>';
}
} else {
$retval .="<tr><td align="center">";
$retval .= $LANG10[21];
$retval .="</td></tr>";
}
$retval .="</table><p>";
$retval .="<center>";
$retval .= '<a href="' . $_CONF['site_url'] . '/phplinks/index.php">More Links</a>';
$retval .="</center>";
return $retval;
}
DO you see gl_linksWHERE cause I can not see it? If it is not here, where is it??
Text Formatted Code
function phpblock_topLinks()
{
global $_TABLES, $_CONF, $LANG10;
$retval .= "<p><table width="100%" border="0">n";
$retval .= "<tr><td><b>Site Name</b></td><td><b>Hits</b></td></tr>";
$result = DB_query("SELECT ID,SiteName,SiteURL,HitsOut from {$_TABLES['pllinks']} WHERE HitsOut > 0 ORDER BY HitsOut desc LIMIT 0, 10");
$nrows = DB_numRows($result);
if ($nrows > 0) {
for ($i = 0; $i < $nrows; $i++) {
$A = DB_fetchArray($result);
$retval .='<tr><td><a href="' . $_CONF['site_url'] . '/phplinks/out_frame.php?&ID=' . $A['ID'] . '">' . $A['SiteName'] . '';
$retval .='</a></td><td>' . $A['HitsOut'] . '</td></tr>';
}
} else {
$retval .="<tr><td align="center">";
$retval .= $LANG10[21];
$retval .="</td></tr>";
}
$retval .="</table><p>";
$retval .="<center>";
$retval .= '<a href="' . $_CONF['site_url'] . '/phplinks/index.php">More Links</a>';
$retval .="</center>";
return $retval;
}
DO you see gl_linksWHERE cause I can not see it? If it is not here, where is it??
17
13
Quote
Status: offline
ScurvyDawg
Forum User
Full Member
Registered: 11/06/02
Posts: 523
bump
16
16
Quote
Status: offline
ScurvyDawg
Forum User
Full Member
Registered: 11/06/02
Posts: 523
Yeah I have been unable to figure out where that syntax error lays. Oh well another block falls by the wayside.
I am going to try to get other things done and may come back to this another time.
I am going to try to get other things done and may come back to this another time.
21
22
Quote
Status: offline
destr0yr
Forum User
Full Member
Registered: 07/06/02
Posts: 324
Text Formatted Code
function phpblock_topLinks()
{
global $_TABLES, $_CONF, $LANG10;
$retval .= '<p><table width="100%" cellspacing="1" cellpadding="1" border="0">' . LB;
$retval .= '<tr><td><b>Site Name</b></td><td><b>Hits</b></td></tr>' . LB;
$sql = DB_query("SELECT ID,SiteName,SiteURL,HitsOut from {$_TABLES['pllinks']} WHERE HitsOut > 0 ORDER BY HitsOut desc LIMIT 0, 10");
$nrows = DB_numRows($sql);
if ($nrows > 0) {
for ($i = 0; $i < $nrows; $i++) {
$A = DB_fetchArray($sql);
$retval .= '<tr><td><a href="' . $_CONF['site_url'] . '/phplinks/out_frame.php?&ID=' . $A['ID'] . '">' . $A['SiteName'] . LB;
$retval .= '</a></td><td>' . $A['HitsOut'] . '</td></tr>' . LB;
}
} else {
$retval .= '<tr><td align="center">' . LB;
$retval .= $LANG10[21];
$retval .= '</td></tr>' . LB;
}
$retval .= '</table><p>' . LB;
$retval .= '<div align="center">' . LB;
$retval .= '<a href="' . $_CONF['site_url'] . '/phplinks/index.php">More Links</a>' . LB;
$retval .= '</div>' . LB;
return $retval;
}
this works for me.
-- destr0yr
"I love deadlines. I like the whooshing sound they make as they fly by." -- Douglas Adams
17
17
Quote
All times are EST. The time is now 02:35 am.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content