Jump to content

[SOLVED] Counting statistics from mysql


graham23s

Recommended Posts

Hi Guys,

 

users on my site can vote 1-10 on different profiles, which get increments (by what ever they vote) ina  `total` table, so if i vote 10 and someone else votes 10 thats 20 and so on.

 

im trying to display the top 10 rated profiles using the count feature but im getting no joy what i have so far is this:

 

     $query5 = "SELECT `total`, COUNT(*) AS `count` FROM `profiles` GROUP BY `total` ORDER BY `count` DESC LIMIT 10";
     $result5 = mysql_query($query5);
     
     echo '<table width="60%" border="1" bordercolor="#000000" cellpadding="2" cellspacing="0" />
           <tr>            
           <th bgcolor="#004E98" colspan="2"><font color="#ffffff">Top 10 Rated Profiles</font></th>
           </tr>            
           <tr>            
           <td width="30%" bgcolor="#004E98" align="center"><font color="#ffffff"><b>Profile Name</b></font></td><td width="30%" bgcolor="#004E98" align="center"><font color="#ffffff"><b>Average Rating</b></font></td>
           </tr>';
           
           while ($row = mysql_fetch_array($result5)) {
           
           // get the usernames clickable.../////////////////////////////////////////////
           
           $name = $row['file_name'];
           $total = $row['total'];
           $id_3 = $row['id'];     
           
           echo '<tr><td align="center"><a href="profile.php?id='.$id_3.'">'.$name.'</a></td><td align="center">'.$total.'</td></tr>';
           
           }          
           
           echo "</table><br /><br />"; 

 

so it kinda displays:

 

graham  50

david  45 etc

 

any help would be appreciated

 

Graham

Link to comment
https://forums.phpfreaks.com/topic/64717-solved-counting-statistics-from-mysql/
Share on other sites

...but im getting no joy...

can you be more specific?

 

so it kinda displays:

 

graham  50

david  45 etc

so is it safe to assume that your code is able to sum the votes and display the profile in the order of highest-to-lowest vote, w/o duplicate profile?

 

regards.

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.