vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   Top Viewed threads (https://vborg.vbsupport.ru/showthread.php?t=34994)

duke 02-11-2002 09:46 PM

Im trying to disply the top viewed threads and did now find a hack to do this. So I tried this but it dont work any ideas on how I can complete this.

// Top 10 Viewed Threads//

$top = "10"; // change this to the number of top thread views you want to disply.

echo("<table border=0 cellpadding=0 cellspacing=0><tr><td><b>Top Viewed Threads </b></td></tr>");

$topthread = mysql_query("SELECT COUNT(*) AS count,title,views FROM thread ORDER BY count DESC LIMIT $top;");
$lugar=1;
while ($topview = mysql_fetch_array($topthread)):
if (($counter++ % 2) != 0);

echo("<tr><td><strong><big>&middot;</big></strong>&nbsp;$lugar: <a href=\"$bburl/showthread.php?&$topthread[title]\">$topthread[threadid]</a></td><td align=\"center\">$topthreads[views]</td></tr>");
$lugar++;
endwhile;

echo("</table>");
echo("<br>");

duke 02-12-2002 01:08 AM

I got it to work with this code I just need some help with excluding some forums form it any ideas how to do this

// Top 10 Viewed Threads//

$top = "10"; // change this to the number of posters you want to show.

echo("<table border=0 cellpadding=4 cellspacing=0><tr><td><b>Top 10 Viewed Threads</b></td><td><br>");
echo("</table>");
echo("<table border=0 cellpadding=0 cellspacing=0><tr><td><b>Thread</b></td><td><b>Viewed</b></td></tr>");

$postsresult = mysql_query("SELECT COUNT(*) AS count,threadid,title,views,forumid FROM thread GROUP BY threadid ORDER BY views DESC LIMIT $top;");
$lugar=1;
while ($vthreads = mysql_fetch_array($postsresult)):
if (($counter++ % 2) != 0);

echo("<tr><td><strong><big>ยท</big></strong> $lugar: <a href=\"$bburl/showthread.php?s&threadid=$vthreads[threadid]\">$vthreads[title]</a></td><td align=\"center\">$vthreads[views]</td></tr>");
$lugar++;
endwhile;

echo("</table>");
echo("<br>");

Admin 02-12-2002 09:49 AM

Add:
Code:

WHERE forumid NOT IN (1,2,3,4,5,...)
to exclude forums.

duke 02-12-2002 01:15 PM

Thanks for the help, When tried

WHERE forumid NOT IN (1,2,3,4,5,...)

I got mysql errors

so I tried this and it works

WHERE forumid<>'1,2,3,4,5'

Admin 02-12-2002 01:24 PM

But it's not correct, because you checking that the forumid is not equal to the STRING '1,2,3,4,5'. Use my code without the ... (I thought that was obvious).

duke 02-12-2002 02:05 PM

Ok thanks, I had it right the first time I tried your code, I had a nother error in the code that was causing my error I just found

Thanks for the Help


All times are GMT. The time now is 06:00 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01017 seconds
  • Memory Usage 1,716KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete