1/2 line of table is displayed

hello !
For simplicity : I want to display all content of a field of my external database table

My field “ID” of my database is this :

ID
2
4
5
6
7
8
9
10

So i write this code to display all the content of the field “ID” :

$result = db_query("SELECT ID FROM {wp_posts} ORDER BY ID");
foreach($result as $record){
      $wp = $result->fetchField();
      print $wp;
    }

But only 1 in 2 lines are displayed on the web page…

ID
2 not displayed
4 displayed
5 not displayed
6 displayed
7 not displayed
8 displayed
9 not displayed
10 displayed

using
var_dump($record);

the result is :

4
object(stdClass)#220 (1) { ["ID"]=> string(1) "2" }

6
object(stdClass)#216 (1) { ["ID"]=> string(1) "5" }

8
object(stdClass)#220 (1) { ["ID"]=> string(1) "7" }

10
object(stdClass)#216 (1) { ["ID"]=> string(1) "9" }

12
object(stdClass)#220 (1) { ["ID"]=> string(2) "11" }

14

Or using
var_dump(get_object_vars($object));
the result is :
4
NULL

6
NULL

8
NULL

10
NULL

12
NULL

14
NULL

16
NULL

18

What’s the problem ?

Drupal version: 


Source: https://www.drupal.org/taxonomy/term/4/feed