kaputski Posted August 18, 2009 Share Posted August 18, 2009 Ok guys I tried using Rand() and it did not work... I also tried to use these other alternatives to Rand() but still no go.. what i'm trying to acheive is sorting my table and some of the results are the same... and i'd like those results randomized in order. The table is for fans who donate to my site, and i'm limiting the number of users displayed on page to 10 so i need the like values to be random so each time the users names will switch out. Here's basically what i'm talking about. Table is set up like this: superfan (table name) | displayname | email | donation | | fan1 | fan@email.com | 15 | | fan2 | fan@email.com | 15 | | fan3 | fan@email.com | 10 | | fan4 | fan@email.com | 5 | | fan5 | fan@email.com | 5 | | fan6 | fan@email.com | 5 | Now lets say i wanted to just limit this to 5 results... i would want the two 15 amounts listed first, then the fan with 10, finally the remaining 2 would show 5... Now i need each each 15 value fans to swich places randomly... the 10 should stay the same spot because there is no other 10... and the 5's should rotate positions randomly so each user will have times where their name is displayed. So basically i need 'donation' sorted first.. highest to lowest, then all like amounts randomly displayed. Here's the code I tried with rand() that didnt work... $query = "SELECT * FROM superfan ORDER BY donation DESC, RAND() LIMIT 15"; Any suggestions? And try to keep it simple or with a good explanation what's going on lol.. I can't do advanced mysql too well Quote Link to comment Share on other sites More sharing options...
kickstart Posted August 18, 2009 Share Posted August 18, 2009 Hi You solution looked OK so I had a try and it appears to work for me. All the best Keith Quote Link to comment 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.