$i = 0; while(mysql_query("select * from tablo order by id desc limit 5)){ if($sutun2 == ""){ $i++; } }