Create Div Wrapper On 3rd Iteration Or When Query Loop Items Run Out

place a single box opening and closing markup outside the loop, then only close/open a new one when it’s every 3rd post and not last by using the built in loop vars current_post and post_count

if( ( ( $your_query->current_post + 1 ) % 3 == 0 )
    && ( $your_query->current_post + 1 ) != $your_query->post_count ){
        // close the box and open a new one.
}

EDIT – note that we add 1 to current_post in each test, as it starts at 0, not 1.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)