Get random results from MySQL, PHP-ThrowExceptions

Exception or error:

I want the different results in the same cell.

My code:

include 'config/connection.php';
$sql=$con->query("SELECT * FROM teams ORDER BY RAND() ");
$teams=$sql->fetch_array(MYSQLI_ASSOC);
        $i=0;
if ($sql){
        while ($teams=$sql->fetch_array(MYSQLI_ASSOC)){
            $logo=$teams['logo'];
            $team=$teams['team'];
           echo "<tr>
                  <td>
                   <h4 class=\"ui image header\"><img src=\"$logo\" class=\"ui mini rounded image\">
                    <img src=\"$logo\" class=\"ui mini rounded image\">
                    <div class=\"content\">
                     $team<br>$team
                    </div>
                   </h4>
                  </td>
                </tr>";
               }
              ?>

Although the above code produces the same results in the same cell. How can I randomize it??? E.g. I want to get the different teams in the same cell, but not similar teams.

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *