Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Random rows

Quote Reply
Random rows
How do I get 1 random rows?
I added a collum in my links database, named "isChoice".
So, in admin I selected some sites. Itīs like a Editor Pick mod.
But I donīt know how, in the mysql code, to get 10 links randonly.
Can anyone help me?

Thanks
Quote Reply
Re: Random rows In reply to
If you have a field "isChoice" why do you want random rows?

Or is it you want 10 random rows from all rows that match "isChoice" ??

What you'd want to do in that case is select all the "isChoice" fields, get the number of records that were returned, and pick 10 unique random numbers with the max value of the number of records.

Then request those records from the returned array (-1 since arrays are 0 based) or iterate through the hash putting the link at each random position into a the output hash, and then operating on that the way you would the New or Popular pages.