It would probably help if you explained:
- What you expected to happen
- What is actually happening
To me, it looks like you are getting a list of articles, including the category of each article. If you want a list of possible categories, you need to select the categories from the database. If you just want a list of categories used by the articles in the list, you should be able to create that list from the data you already have.