while (nodeptr != NULL) is the same as while (nodeptr). The latter is a compact way to check whether any variable != 0. In this case it is used to check whether the pointer != 0, i.e,, it is not equal to NULL.
However, nodeptr->next is another pointer different from nodeptr.
Hence, while(nodeptr->next!=NULL) checks whether the "next" pointer is not equal to NULL.