表3列循环

I have read all the post about coding three columns for PHP. However, I can't seem to find any that will allow me to create three column loop. Everything I do either gives me an error or a blank white page. I also need to have a little space between the column loops. Here is what I have so far, can you tell me what I am missing?

table, td, th {    
    border: 1px solid #000;
    text-align: left;
}

table {
    border-collapse: initial;
    width: 100%;

}

td {
    padding: 10px;
    width: 5%;
    line-height: 2;
  
}

th  {
    background-color: grey;
       color: white;
       padding: 15px;
       width: auto;
    
    
}
$sql = "SELECT name, email, dropdown, description FROM basic";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    echo "<table>";
    $columns=3;
    // output data of each row
    while($row = $result->fetch_assoc()) {
        if ($row > 0 && ($columns) == 3) {
            echo "<th>". $row["name"]. "</th><tr> <td>email: ". $row["email"]. "</td><tr> <td>category: " . $row["dropdown"] . "</td><tr><td>Announcement: " . $row["description"] . "</td></tr>";
        }
    }
    echo "</table>";
} else {
    echo "0 results";
}
$conn->close();

</div>
$sql = "SELECT name, email, dropdown, description FROM basic";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    echo "<table>";
    $columns=3;
    $x = 0;
    // output data of each row
    echo "<tr>";
    while($row = $result->fetch_assoc()) {
        if ($row > 0 && ($columns) == 3) {
            echo "<th>". $row["name"]. "</th><tr> <td>email: ". $row["email"]. "</td><tr> <td>category: " . $row["dropdown"] . "</td><tr><td>Announcement: " . $row["description"] . "</td></tr>";

            if ($x == 3) {
                echo "</tr>";
                $x = 0;
            }

            $x++;
        }
    }
    if ($x < 3) {
        echo "</tr>";
    }
    echo "</table>";
} else {
    echo "0 results";
}
$conn->close();

Explaination :- within the while loop , we will check the variable $x which we set it to 0 outside the loop and increment it for every iteration , when that variable be equal to 3 we will print the end of row </tr>