Jump to content

Help with getting top 10 most visited


cordoprod

Recommended Posts

Hi.

 

I have a DB and my structure is like this.

nick | Monday | Tuesday | Wednesday | Thursday | Friday | Saturday | Sunday | total

 

The weekdays only contain numbers like 2 and 4 ..

What i want to do is to plus them (+) ..

 

So i get the total of the weekdays, and then i want to get the 10 most visited and sort them like this:

1. username1

2. username2

 

and so on..

 

Do you understand?

Link to comment
https://forums.phpfreaks.com/topic/107099-help-with-getting-top-10-most-visited/
Share on other sites

Try

 

<?php

$query = "SELECT nick, (Monday + Tuesday + Wednesday + Thursday + Friday + Saturday + Sunday) AS added FROM table_name
ORDER BY added DESC LIMIT 10";

$result = mysql_query($query)or die(mysql_error());

$i = 0;
while ($row = mysql_fetch_assoc($result)){
   echo $i .'. '.$row['nick'].'<br />';
   $i++;
}

?>

Try

 

<?php

$query = "SELECT nick, (Monday + Tuesday + Wednesday + Thursday + Friday + Saturday + Sunday) AS added FROM table_name
ORDER BY added DESC LIMIT 10";

$result = mysql_query($query)or die(mysql_error());

$i = 0;
while ($row = mysql_fetch_assoc($result)){
   echo $i .'. '.$row['nick'].'<br />';
   $i++;
}

?>

 

Thanks =)

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.