Note that this method is a very VERY uneconomical (read: bad) way of doing it.
"SELECT * FROM table" will select ALL rows, while you only need one. (imagine doing that on a 5 million-row table)
Istead, select all the record-IDs, use PHP's randomize functions to grab a random ID, and then select the record with that ID.