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
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++;
}

?>

Link to comment
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++;
}

?>

 

Thanks =)

Link to comment
Share on other sites

Just one more thing..

 

Is it possible to split it up in to sides so it looks more like this:

 

1. username    6. username

2. username    7. username

3. username    8. username

4. username    9. username

5. username    10. username

Link to comment
Share on other sites

Does anyone know?

 

I suspect that lots of people who have looked at your problem have ideas on how to do that.  Why don't you show us your code effort - we're here to help you help yourself, not to write code for you.

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.