Jump to content

Using count for statistics


graham23s

Recommended Posts

Hi Guys,

 

i want to display in the statistics howe many files have been downloaded by each user then have the last 10 records displayed in my table i have:

 

id

file_id

downloader_id

 

this is the test query:

 

     $query4 = "SELECT * FROM `whos_downloaded` LIMIT 10";
     $result4 = mysql_query($query4);
     
     echo '<table width="60%" border="1" bordercolor="#000000" cellpadding="2" cellspacing="0" />
           <tr>            
           <th bgcolor="#004E98" colspan="2"><font color="#ffffff">Top 10 Downloaders</font></th>
           </tr>            
           <tr>            
           <td width="30%" bgcolor="#004E98" align="center"><font color="#ffffff"><b>Downloader</b></font></td><td width="30%" bgcolor="#004E98" align="center"><font color="#ffffff"><b>Number Of Files Downloaded</b></font></td>
           </tr>';
           
           while ($row_dl = mysql_fetch_array($result4)) {
           
           $nzb_id_2 = $row_dl['file_id'];
           $dl_id_2 = $row_dl['downloader_id'];
           
                      
           echo '<tr><td></td><td></td></tr>';
           
           }          
           
           echo "</table><br /><br />"; 

 

i'm not sure what to do next to group the results any help would be great.

 

thanks guys

 

Graham

Link to comment
Share on other sites

well if u want to count how many for each user, then you can use mysql_numrows() on a query like

$q = mysql_query(SELECT * FROM `downloaded` WHERE `downloaderid`='"$_SESSION['userid']"'")

This is assuming u have a membership system where each user has sessions,

 

then you would go

$num = mysql_numrows($q);
echo "$num";

 

or you can use COUNT instead of mysql_numrows, but numrows proved better for me

EDIT:

then have the last 10 records displayed in my table i have:

can u expand on this and explain...u want it to show the user's last ten, or the last ten users who downloaded something?

Link to comment
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.