Non ti basta una SELECT * FROM table ORDER BY RAND() ?