Jump to content

help needed!?!


seany123

Recommended Posts

im making a page which shows the top 20 refferers on my website but i dont really fancy adding another database value for it so im gonna try doing it using the values i have already:

 

basically every user on the website has a value in the table called ref.. if its >= 1 then it corresponds to another users ID....

 

so what i need to do is find the users with the most amount of IDs in other players ref value.

 

 

so basically i need a way so it will find everyones $refcount not just mine...

 

this is how i would get my $refcount

 

//REFFERAL COUNT
$query5 = $db->execute("select * from `users` where `ref`=?",array($user->id));
$refcount = $query5->recordcount();

Link to comment
https://forums.phpfreaks.com/topic/189699-help-needed/
Share on other sites

well actually, nvm that won't exactly work, well it WOULD but it would be a waste of resources, I'd just take the list for example..

 

SELECT COUNT(*) as num, ref FROM members GROUP BY ref ORDER BY num DESC LIMIT 20

 

and then run queries on each of the ref ids like so:

 

<?php
while ($r = mysql_fetch_assoc($r)) {
  $referer = mysql_fetch_object(mysql_query("SELECT * FROM members WHERE id = '{$r['ref']}'"));
  // $referer->username  will be the user's username..
  
}
?>

Link to comment
https://forums.phpfreaks.com/topic/189699-help-needed/#findComment-1001426
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.