PDA

View Full Version : top 5 posters


09-13-2000, 09:06 AM
Hi all I'm trying to do the top 5 posters hack like on http://www.extremeforums.com. But have no idea how to do this.

Any help would be greatly apreciated.

JP

09-13-2000, 09:14 AM
it's all in this thread

http://www.vbulletin.com/forum/showthread.php?threadid=2658

09-13-2000, 09:39 AM
thanks but...
Once I have the text below to I just include it in the template in the vb control panel?
cheers
JP


<?php
// Set this to the max number top posters to display
$num = 20;

require("admin/config.php");
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
$query = "SELECT * FROM user ORDER BY posts DESC LIMIT $num";
$resultlatest = mysql_query($query,$db);
while ($latest_array = mysql_fetch_array($resultlatest)) {
echo "<FONT SIZE=\"1\" FACE=\"Verdana, Arial, Helvetica, sans-serif\">&nbsp;°
<A HREF=\"http://animeboards.net/forums/member.php?action=getinfo&userid=$latest_array[userid]\">$latest_array[username]</A></FONT><BR>";
}

09-13-2000, 09:45 AM
save it in a file like top5.php3

and then use an include command into your non vb page

09-13-2000, 09:47 AM
right like this:

1/ save file as top5.php3 in admin folder.
2/ create include (how?) in forumhome template.
3/ end

Is this right?

09-13-2000, 09:52 AM
errhh... the you want the top 5 posters where on your site ?

what i did was only put it on my front index page which is a non vb page.. then i used a php include on my front index.php3 page at http://animeboards.net i saved top5.php3 into my root directory

<?php
include("/home/usr1/www.animeboards.net/htdocs/top5.php3");
?>

09-13-2000, 10:00 AM
oh I want to include it on my forum category page --> forumhome template.

http://216.10.4.112/forums/index.php

Is this easier?
JP

09-13-2000, 10:03 AM
well i don't know anything about php really just code that others here have given me... so that's where my knowledge ends... i haven't tried php code in the forumhome template before ... you can try it though... :)

09-13-2000, 10:16 AM
OK, I'll try - how do I include the file?
JP

PS Thanks for all your help!

09-13-2000, 01:53 PM
include("top3.php3");

09-13-2000, 03:08 PM
that just displays the txt. What should it be surrounded with?

09-13-2000, 03:19 PM
I don't think you can put php into the templates.

but you can try

<?php include("top3.php3") ?>

09-13-2000, 03:22 PM
thanks but doe snot work. any idea what to do now?

I would lovethis feature.
JP

09-13-2000, 03:37 PM
I just posted the include command like you wanted. I assumed you knew to put the opening and closing PHP tags there.

rangersfan had it right, but forgot the semicolon I think...c'mon JP, troubleshoot! :D

<?php include("top5.php3"); ?>

Make sure top5.php3 is in the same directory...if it's not, you'll have to include the relative path.

09-13-2000, 03:38 PM
Well you can open index.php and place this code after require("global.php")


// Set this to the max number top posters to display
$num = 5;
$sql = "SELECT userid,username FROM user ORDER BY posts DESC LIMIT $num";
$results = $DB_site->query($sql);
while ($result = $DB_site->fetch_array($results))
{
$top5 .= "<FONT SIZE=\"1\" FACE=\"Verdana, Arial, Helvetica, sans-serif\">&nbsp;°
<A HREF=\"member.php?action=getinfo&userid=$result[userid]\">$result[username]</A></FONT><BR>";
}


OR

put this in a file called top5.php

<?php
// Set this to the max number top posters to display
$num = 5;
$sql = "SELECT userid,username FROM user ORDER BY posts DESC LIMIT $num";
$results = $DB_site->query($sql);
while ($result = $DB_site->fetch_array($results))
{
$top5 .= "<FONT SIZE=\"1\" FACE=\"Verdana, Arial, Helvetica, sans-serif\">&nbsp;°
<A HREF=\"member.php?action=getinfo&userid=$result[userid]\">$result[username]</A></FONT><BR>";
}
?>


and then put require("top5.php"); after require("global.php");

then for either way you put $top5 in your forumhome template where you want the results to show up.

[Edited by rangersfan on 09-13-2000 at 12:58 PM]

09-13-2000, 03:39 PM
TWT nah it would work without the semi-colon if there is only one command.

09-13-2000, 03:50 PM
sorry guys, as i'm sure you've guessed my strength is not coding.

rangersfan, the latter did not work.

is it because of the several double quotes?

09-13-2000, 03:56 PM
Try it now, both ways work for me now.

09-13-2000, 04:01 PM
once again thanks, but not working.

1/ I have top.php in the admin folder

[quote]
<?php
require("global.php");
// Set this to the max number top posters to display
$num = 5;
$sql = "SELECT userid,username FROM user ORDER BY posts DESC LIMIT $num";
$results = $DB_site->query($sql);
while ($result = $DB_site->fetch_array($results))
{
$top5 .= "<FONT SIZE=\"1\" FACE=\"Verdana, Arial, Helvetica, sans-serif\">&nbsp;°
<A HREF=\"member.php?action=getinfo&userid=$result[userid]\">$result[username]</A></FONT><BR>";
}
?>
[quote]

I also have edited index.php and added $top5 into forumhome template.....help......
JP

09-13-2000, 04:09 PM
Put top5.php in the forums folder, not the admin folder. Remove the require("global.php"); from the top5.php so that it matches what I told you to do.

09-13-2000, 04:29 PM
OK.

top5.php in forums
index.html with require("top5.php"); in forums/admin
$top5 in forumhome

still not workig :(

I tried require("../top5.php"); just in case.

an ideas?
JP

09-13-2000, 04:46 PM
no no no

We are not touching anything in the admin directory, stay out of there!

Edit the index.php in /forums!

09-14-2000, 12:33 AM
i know it is possible but what is the code to show how many posts the user has after his/her name?? tia

i always do this, i post a question and then blam. i figure it out.

$latest_array[posts]

[Edited by poil11 on 09-13-2000 at 09:41 PM]

09-14-2000, 08:24 AM
yes! thanks, I know it took me a while but thanks so much!

one more teeny thing...
I want to clean the actual code up by adding more templates. I added navbar template and then in forumhome template I called $navbar but it did not work. What should I do?
Thanks!
JP

09-14-2000, 10:09 AM
Originally posted by JP Stones
yes! thanks, I know it took me a while but thanks so much!

one more teeny thing...
I want to clean the actual code up by adding more templates. I added navbar template and then in forumhome template I called $navbar but it did not work. What should I do?
Thanks!
JP

check this thread
http://www.vbulletin.com/forum/showthread.php?threadid=2884

09-14-2000, 03:01 PM
hmmm, I thought I was clear on that but oppened global.php and realised i was reading chinese.

I promise I will get better but this is my first venture into php (or anything similar) and I'm hesitant. A quick step by step would be apreciated.
JP