Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.