$i = 0; while ($row = $DB_site->fetch_array($query)) { if ($i % 2) { // put in odd colum } else { // put in even colum } $i++; }