PDA

View Full Version : Top 25 Posters


12-16-2000, 12:39 AM
We are working on trying to use the include for top 25 posters on our index.php page...and we keep getting an error. We managed to put the latest 12 posts on the index.php page but adding the top posters isn't working.

COuld someone post the perfect :lol: script here with simple instructions for me to follow?

I would sure appreciate it! :)

Thanks!
Kathy

12-16-2000, 07:13 AM
untested, but it should work


<?
mysql_connect($my_host, $my_user, $my_pass);
mysql_select_db($dbase);

$action = mysql_query("SELECT userid, username from user ORDER BY posts DESC LIMIT 1,25");

while(list($userid, $username) = mysql_fetch_row($action)){
echo "<a href=\"member.php?action=getinfo&userid=$userid\">$username</a><br>";
}
?>


[EDIT: My mistake, try again :)]

[Edited by Menno on 12-16-2000 at 11:15 AM]

12-16-2000, 10:52 AM
Hmmm gives me a:

Parse error: parse error, expecting `','' or `';'' in /usr/local/etc/httpd/vhosts/friendswithoutfaces.com/htdocs/hot1.inc.php on line 9


Bet it's close, though.

12-16-2000, 02:16 PM
try again

hm.... I really shouldn't code so late :)

12-16-2000, 05:22 PM
hmmm

Warning: 0 is not a MySQL result index in /usr/local/etc/httpd/vhosts/friendswithoutfaces.com/htdocs/hot1.inc.php on line 8

12-16-2000, 05:45 PM
You DID fill in the variables, right?

If so, change

$action = mysql_query("SELECT userid, username from user ORDER BY posts DESC LIMIT 1,25");

to

$action = mysql_query("SELECT userid, username from user ORDER BY posts DESC LIMIT 1,25") or die("Error: ".mysql_error());

that'll give you the error message :)

12-16-2000, 07:27 PM
Here is the code I was using on vBoard for a short time:-


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


$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\"> ?
<A HREF=\"http://yourdomain/forums/member.php?action=getinfo&userid=$latest_array[userid]\">$latest_array[username]</A> ($latest_array[posts])</FONT><BR>";
}

?>

See this:
<A HREF=\"http://yourdomain/forums/member.php?action=getinfo&userid=$latest_array[userid]

That url change it to the path to your member.php file like http://www.vboard.co.uk/board/member.php

That will display the top 25 posters.

12-17-2000, 01:49 AM
We're getting closer! Now I get:

Error: No Database Selected

Now I have filled in the variables, so I'm not sure what the problem is this time.

12-17-2000, 07:39 AM
sure you filled in $dbase? That's the only thing I can think of

12-17-2000, 07:41 AM
BTW, you got the earlier error message because I forgot to add slashes to the " chars :)

12-17-2000, 11:14 AM
Okay....let's say that I Operate fwf.com and have a database called fwfdb and the username is fwfname and the password is fwfpass . My file looks like this:

<?php

mysql_connect($fwf.com, $fwfname, $fwfpass);
mysql_select_db($fwfdb);

$action = mysql_query("SELECT userid, username from user ORDER BY posts DESC LIMIT 1,25") or die("Error: ".mysql_error());

while(list($userid, $username) = mysql_fetch_row($action)){
echo "<a href=\"http://friendswithoutfaces.com/forums/member.php?action=getinfo&userid=$userid\">$username</a><br>";
}
?>

12-17-2000, 02:01 PM
Nonono, they should be like this:

mysql_connect(fwf.com, fwfname, fwfpass);
mysql_select_db(fwfdb);

$ denotes a variable.

12-17-2000, 02:14 PM
lol, yeah, don't make variables out of everything

if you don't want to get your head in a knot just add:

$my_user = "fwfname";
$my_pass = "fwfpass";
$dbase = "fwfdb";

above

my_host, $my_user, $my_pass);
mysql_select_db($dbase);

12-17-2000, 04:08 PM
I have been trying to get this one for along time and have been very unsuccesful

If I use this

<?php
// Set this to the max number top posters to display
$num = 25;
$db=mysql_connect(tuffsports.com, username, password);
mysql_select_db(database);
$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\"> °
<A HREF=\"http://tuffsports.com/forum/member.php3?action=getinfo&userid=$latest_array[userid]\">$latest_array[username]</A> ($latest_array[posts])</FONT><BR>";
}

?>

I am getting a parse error with line four

12-17-2000, 07:29 PM
Originally posted by Zecherieh
I have been trying to get this one for along time and have been very unsuccesful

If I use this


<?php
// Set this to the max number top posters to display
$num = 25;
$db=mysql_connect(tuffsports.com, username, password);
mysql_select_db(database);
$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\"> ?
<A HREF=\"http://tuffsports.com/forum/member.php3?action=getinfo&userid=$latest_array[userid]\">$latest_array[username]</A> ($latest_array[posts])</FONT><BR>";
}

?>

I am getting a parse error with line four

Try using quotes, ie:

$db=mysql_connect("tuffsports.com", "username", "password");
Hope that helps :)

12-17-2000, 08:18 PM
Thanks Guys for your patience! It's working like a charm now!

12-18-2000, 09:55 AM
which of the 5 versions are you using? :D

12-18-2000, 12:07 PM
ROFL.....errrrrr....I think it may be a new version which is a conglomerate of all of them. <G>

<?php

mysql_connect(mydomain.com, myusername, mypassword);
mysql_select_db(mydatabasename);

$action = mysql_query("SELECT userid, username from user ORDER BY posts DESC LIMIT 1,25") or die("Error: ".mysql_error());

while(list($userid, $username) = mysql_fetch_row($action)){
echo "<a href=\"http://mydomain.com/forums/member.php?action=getinfo&userid=$userid\">$username</a><br>";
}
?>

12-18-2000, 12:36 PM
good choise ;)

it seems to be the least 'cluttered'

12-18-2000, 03:04 PM
Originally posted by Susan
ROFL.....errrrrr....I think it may be a new version which is a conglomerate of all of them. <G>

<?php

mysql_connect(mydomain.com, myusername, mypassword);
mysql_select_db(mydatabasename);

$action = mysql_query("SELECT userid, username from user ORDER BY posts DESC LIMIT 1,25") or die("Error: ".mysql_error());

while(list($userid, $username) = mysql_fetch_row($action)){
echo "<a href=\"http://mydomain.com/forums/member.php?action=getinfo&userid=$userid\">$username</a><br>";
}
?>



One small change

user ORDER BY posts DESC LIMIT 0,24")

with 1,25 it was starting with the number two poster, 0 brought it to the number one poster

12-18-2000, 03:18 PM
Actually, LIMIT 0,25. Or, even better, LIMIT 25. The first number is the beginning (remember, computers start with 0), and the second is how many to get. Thats why it's LIMIT 25,5, not LIMIT 25,30.

Get it? Got it? Good.

12-18-2000, 03:38 PM
I just got this one to work perfectly for me, finally

I was missing that little bit of knowledge Menno threw in about putting " " around the database name and such

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

$db=mysql_connect("localhost","YOURDATABASEUSERNAME","YOURDATABASEPASSWORD");
mysql_select_db("YOURDATABASENAME");
$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\"> $rank
<A HREF=\"http://yourdomain/forums/member.php?action=getinfo&userid=$latest_array[userid]\">$latest_array[username]</A> ($latest_array[posts])</FONT><BR>";
$rank = ($rank+1);
}

?>

Made one little change so it will show the number rank instead of just the little character

12-19-2000, 12:53 AM
heh...we noticed tonight that the number one person was missing....and since there seems to be a bit of a contest to see who can be the top poster, this was really funny to me. She tried so hard to be number 1 and then wasn't shown in the top posters at all. LOLOLOLOL Okay...fixing it.

12-19-2000, 12:44 PM
whoops, ever so sorry about the 1,25 thing :)
it's been hectic, so my coding has been shit lately

12-19-2000, 01:46 PM
Originally posted by Menno
whoops, ever so sorry about the 1,25 thing :)
it's been hectic, so my coding has been shit lately



No reason to apoligize, a little oversite by you can make the rest of us learn a lot. Figuring out little tiny details is just the first step of building a knowledge to acutally be able to program in - hell I was pumped when I figured it enough to make it count and put out the right rank number.

So I take pleasue in the simple things, but since I have not coded in over ten years and never heard of php until about two months ago I am happy.