×

Welcome to TagMyCode

Please login or create account to add a snippet.
2
0
 
1
Language: PHP
Posted by: Tamás Máté
Added: Aug 20, 2014 11:38 AM
Modified: Aug 20, 2014 11:42 AM
Views: 30
Tags: random sql
  1. $offset = $db->query("SELECT FLOOR(RAND() * COUNT(*)) AS `offset` FROM `{$table}` ")->fetch();
  2. $result = $db->query("SELECT * FROM `{$table}` LIMIT {$offset['offset']}, 1 ");