使用单链接列表插入哈希表

I'm new here, I need some help with this problem, the problem is that it stores value for the first entry, but when I'm creating a list, for example when I want to insert 22, after I have inserted 2 before, it behaves as if it added the node after 2, but actually it doesn't create and I don't know why. Need assistance on this one, please.

 void insertKey(int key) {

        int i = Hash(key);
        Node* temp = HashTable[i];

        Node* NewNode = new Node;
        NewNode->key = key;
        NewNode->next = NULL;
        if (temp == NULL) {
            HashTable[i] = NewNode;
        }
        else
        {
            while (temp != NULL) {
                cout << "NOTHere ";
                temp = temp->next;
            }
            if (temp == NULL) {
                cout << "FoundYa ";
                temp = NewNode;
            }
        }
    }