graham23s Posted July 15, 2007 Share Posted July 15, 2007 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 Quote Link to comment Share on other sites More sharing options...
L Posted July 15, 2007 Share Posted July 15, 2007 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? Quote Link to comment Share on other sites More sharing options...
graham23s Posted July 16, 2007 Author Share Posted July 16, 2007 Hi mate, basically it's for a section called top ten that's why i capped them at 10, do i not neet the COUNT function at all? thanks mate Graham Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.