Log in

View Full Version : Please Help


babolo
05-12-2005, 02:53 AM
I am trying to make a top 10 poster in my php include. This is what I have so far.
$result = mysql_query("SELECT userid,username,posts
FROM user
ORDER BY posts
DESC LIMIT 10");

$s = mysql_fetch_array($result, MYSQL_NUM);
$userid = $s[0];
$username = $s[1];
$posts = $s[2];


$topposters = "Our top poster is <a href=\"member.php?u=".$s[0]."\">".$s[1]."</a>(".$s[2].")";

can somebody please help me so I can get the top posters?

Marco van Herwaarden
05-12-2005, 09:35 AM
try with:
$username = $s['username'];

babolo
05-12-2005, 01:25 PM
The coding wqorks fine. Its just my problem is I need help turning it into the top 10 posters instead of the just the top poster.

Marco van Herwaarden
05-12-2005, 03:31 PM
Then use:
$result = mysql_query("SELECT userid,username,posts
FROM user
ORDER BY posts
DESC LIMIT 10");

while ($s = mysql_fetch_array($result, MYSQL_NUM))
{
.......your work here......
}

babolo
05-12-2005, 07:47 PM
Nope doesnt work. :( Is there anyone else who could help, or do you have anymore suggestions?

Actually it did work... but I still have a problem. I have to figure out how to put it under the stats section.

$result = $DB_site->query("SELECT userid,username,posts
FROM user
ORDER BY posts
DESC LIMIT 10");


while ($s = $DB_site->fetch_array($result, MYSQL_NUM))
{
echo "<a href=\"member.php?u=".$s[0]."\">".$s[1]."</a>(".$s[2].")";
} thats my code.

Ok I got everything working fine now