shuffle db table order

simple code to shuffle a table … with php shuffle: $result = $mysql->query(“SELECT id FROM $table ORDER BY id”); $rows = $result->num_rows; $order = shuffle(range(1,$rows)); while($row=$result->fetch_row()) { $num=array_shift($order); $mysql->query(“UPDATE $table SET rand_sort=$num WHERE id=”.$row[0]); } added: with MySQL RAND(): $result = $mysql->query(“SELECT id FROM $table ORDER BY RAND()”); for($i=1;$row=$result->fetch_row();$i++) { $mysql->query(“UPDATE $table SET rand_sort=$i WHERE […]