Wouldn't that be more likely caused by the CSS for the image, rather than the PHP code used to display it? After all, once it's on the browser the PHP is all finished with.
Also this is a bit strange, don't you get a parse error?
while ($rows = mysqli_fetch_array($result))
and then at the end
<? endwhile; ?>
unless there's another
while() clause before the start of the code you posted.
Another weird thing is the way you nest
<div>s around the loop. You open and close a total of five nested
<div>s, but the first one is opened before you start the while loop, but closed inside the loop. So every time you go around the loop from the second time on, you're closing a
<div> that you didn't open (again, unless there are more opened beforehand). I'm not sure what difference this will make - perhaps none in practice - but it doesn't sound like a good thing to do. At the very least it would (probably, I am out of touch with CSS) mean that the second and subsequent items aren't within the
<div class="w3ls_mobiles_grid_right_grid3"> div, so might affect how they are styled.