n3p3 Posted June 24, 2009 Share Posted June 24, 2009 Hello, In a web project, let's say we have a thousand users. In our algorithm, first we randomly determine a lucky user and we want to notify other users how close they're to the lucky user. Example, user_id 365 -> lucky user my user_id 360 and in my page it should say 5 user away from the lucky user.. We cannot determine it using user_id cause there may be some irregularities due to the deleted user rows. Any suggestions on how to determine the difference between lucky user and others. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/163513-help-on-a-listing-algorithm/ Share on other sites More sharing options...
corbin Posted June 24, 2009 Share Posted June 24, 2009 The first thing that comes to mind is: SELECT COUNT(user_id) FROM users WHERE user_id BETWEEN $winner_id AND $loser_id; (Which ever one is less will need to be first.) Quote Link to comment https://forums.phpfreaks.com/topic/163513-help-on-a-listing-algorithm/#findComment-862746 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.