Loop increase in while loop not working

You’re reassigning 1 to $i on every loop:

if ( $i = 1) { 

This should be

if ( $i == 1) { 

or even

if ( $i === 1) { 

which will also compare the post type, which is best practice.

In PHP, = is assignment, == is comparison:

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