How can the OFFSET parameter in a LIMIT clause affect the results of a SQL query in PHP?

When using the OFFSET parameter in a LIMIT clause in a SQL query in PHP, it can affect the results by skipping a specified number of rows before starting to return data. This can be useful for pagination purposes, but it's important to be mindful of the potential performance impact when dealing with large datasets. To mitigate this, consider optimizing your query or limiting the number of rows returned.

// Example of using OFFSET parameter in a LIMIT clause to paginate results
$offset = 10; // Number of rows to skip
$limit = 10; // Number of rows to return

$sql = "SELECT * FROM table_name LIMIT $limit OFFSET $offset";
$result = mysqli_query($conn, $sql);

// Process the query result
if (mysqli_num_rows($result) > 0) {
    while ($row = mysqli_fetch_assoc($result)) {
        // Process each row here
    }
} else {
    echo "No results found.";
}