如何使用php以随机方式显示mysql的输出

I want to display output from mysql using php in random manner. by default whole array will be displayed sequentially.

echo "<table border='1'>

</tr>
<tr>
<th>User ID</th>
<th>User </th>
<th>Site </th>
<th>IP Address</th>
<th>Date</th>
</tr>";

while($row = mysqli_fetch_array($result))
  {
  echo "<tr>";
 echo "<td>" . $row['userID'] . "</td>";
  echo "<td>" . $row['user_name'] . "</td>";
  echo "<td>" . $row['site_name'] . "</td>";
  echo "<td>" . $row['ip_address'] . "</td>";
  echo "<td>" . $row['date'] . "</td>";
   echo "</tr>";
  }
echo "</table>";

I want to output to be displayed randomly on each access.

i.e. row1 is displayed on first access on top of output. row10 is displayed on 2nd access on top of output. row13 is displayed on 3rd access on top of output.

thanks for suggestions and help.

you can use mysql rand() for the purpose:

For eg:

SELECT * FROM myTable ORDER BY RAND();

You can use ORDER BY RAND() in your sql query

SELECT * FROM `table_name` ORDER BY RAND()

You can also shuffle your php array using shuffle($my_array);

You can also use

function shuffle_assoc($list) { 
  if (!is_array($list)) return $list; 

  $keys = array_keys($list); 
  shuffle($keys); 
  $random = array(); 
  foreach ($keys as $key) { 
    $random[$key] = $list[$key]; 
  }
  return $random; 
}