How can PHP be used to output two names per row in a table if the number of rows fetched from MySQL is greater than 10?

When fetching data from MySQL, if the number of rows is greater than 10 and you want to display two names per row in a table, you can achieve this by iterating through the fetched data and using a counter to determine when to start a new row. You can use a combination of PHP's `mysqli_fetch_assoc()` function to fetch the data and HTML to structure the table with two names per row.

// Assuming $result contains the fetched data from MySQL

echo "<table>";
$count = 0;

while ($row = mysqli_fetch_assoc($result)) {
    if ($count % 2 == 0) {
        echo "<tr>";
    }

    echo "<td>" . $row['name'] . "</td>";

    if ($count % 2 != 0 || $count == mysqli_num_rows($result) - 1) {
        echo "</tr>";
    }

    $count++;
}

echo "</table>";