How can PHP developers effectively communicate their coding issues to seek help from forums or communities?

I am experiencing an issue with a PHP script where the data from my database is not being displayed correctly on my webpage. I suspect it may be an issue with my SQL query or how I am fetching and displaying the data.

// Connect to the database
$connection = mysqli_connect("localhost", "username", "password", "database");

// Check connection
if (!$connection) {
    die("Connection failed: " . mysqli_connect_error());
}

// Fetch and display data from the database
$sql = "SELECT * FROM table_name";
$result = mysqli_query($connection, $sql);

if (mysqli_num_rows($result) > 0) {
    while ($row = mysqli_fetch_assoc($result)) {
        echo "ID: " . $row["id"] . " - Name: " . $row["name"] . "<br>";
    }
} else {
    echo "0 results";
}

// Close connection
mysqli_close($connection);