mazman13 Posted September 14, 2006 Share Posted September 14, 2006 Ok, I have a script that picks a random number based on the number of banners in my database.The number is used to pick a rank number in the banners.example: random number 1, so it picked picture.jpg (rank no. 1) from the database and plays it.Is there a way, to just have it pick a row number. example: SELECT * FROM database WHERE COL NUMBER IS (random number from script)cuz the way i have it now, if i erase a banner now, the image rank is erased, so some banners might now be picked. can i get info from a row number? i hope people can understand what i'm saying...ask questions if you don't understand...i havn't slept much this week. Quote Link to comment Share on other sites More sharing options...
AndyB Posted September 14, 2006 Share Posted September 14, 2006 SELECT * from $tablename ORDER by RAND LIMIT 1 Quote Link to comment Share on other sites More sharing options...
mazman13 Posted September 14, 2006 Author Share Posted September 14, 2006 Wow! thats it? I don't even need that random PHP script huh? it will pick somethin on random huh? Quote Link to comment Share on other sites More sharing options...
AndyB Posted September 14, 2006 Share Posted September 14, 2006 Sorry it's so simple, but yes that will pick a single random row without any help from anything else ;D Quote Link to comment Share on other sites More sharing options...
mazman13 Posted September 15, 2006 Author Share Posted September 15, 2006 Code works great, just one lil' thing to fix to make it work:SELECT * FROM $tablename ORDER BY RAND[b]()[/b] LIMIT 1 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.