I want to select the users from a database called log_buyers. log_buyers is a log with all items i sold to users. I use DISTINCT on field USERID to collect only the buyers one time (some people buy more items). I use it like this:
$lsel_log = mysql_query("select DISTINCT userid from log_buyers order by id");
while ($log = mysql_fetch_array($lsel_log)) {
Now i want to have the 10 most common users and see how much each user in the top paid. In the same table (log_buyers).
$lsel_log = mysql_query("select DISTINCT userid from log_buyers order by id");
while ($log = mysql_fetch_array($lsel_log)) {
$lsel_total_5 = mysql_query("select * from log_buyers where userid = '$log[userid]' order by id desc");
$total = mysql_num_rows($lsel_total_5);
$total = $total * 5;
echo "$log[userid] - $total";
The code works fine, except he is doing it for all the users who bought. I only want to do it for the top 10 users. (Most common in log_buyers).