cordoprod Posted May 24, 2008 Share Posted May 24, 2008 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? Quote Link to comment https://forums.phpfreaks.com/topic/107099-help-with-getting-top-10-most-visited/ Share on other sites More sharing options...
pocobueno1388 Posted May 24, 2008 Share Posted May 24, 2008 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++; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/107099-help-with-getting-top-10-most-visited/#findComment-549066 Share on other sites More sharing options...
cordoprod Posted May 24, 2008 Author Share Posted May 24, 2008 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 =) Quote Link to comment https://forums.phpfreaks.com/topic/107099-help-with-getting-top-10-most-visited/#findComment-549077 Share on other sites More sharing options...
cordoprod Posted May 24, 2008 Author Share Posted May 24, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/107099-help-with-getting-top-10-most-visited/#findComment-549095 Share on other sites More sharing options...
.josh Posted May 24, 2008 Share Posted May 24, 2008 Yes. There are a hundred ways you could make it look like that. I suggest choosing the one most consistent with the rest of your page design. Quote Link to comment https://forums.phpfreaks.com/topic/107099-help-with-getting-top-10-most-visited/#findComment-549096 Share on other sites More sharing options...
cordoprod Posted May 24, 2008 Author Share Posted May 24, 2008 Could you show some code? Quote Link to comment https://forums.phpfreaks.com/topic/107099-help-with-getting-top-10-most-visited/#findComment-549097 Share on other sites More sharing options...
cordoprod Posted May 24, 2008 Author Share Posted May 24, 2008 Does anyone know? Quote Link to comment https://forums.phpfreaks.com/topic/107099-help-with-getting-top-10-most-visited/#findComment-549105 Share on other sites More sharing options...
AndyB Posted May 24, 2008 Share Posted May 24, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/107099-help-with-getting-top-10-most-visited/#findComment-549243 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.