I try to use the script https://drupal.org/node/1772498, but I don't get the right db_query for countries in the nodes. I change the script on these line:

$result = db_query("SELECT DISTINCT(l.country) FROM {location} l ORDER BY l.country ASC");

and get the error message:

Notice: Undefined offset: 1 in DatabaseStatementBase->fetchAllKeyed() (line 2180 of E:\xampp\htdocs\testsite\includes\database\database.inc).

It will be great, if somebody can help me!

2 Answers 2


fetchAllKeyed requires a 2-column resultset. You only have 1 column l.country in your resultset. I'm infering from your question here ...

  • Did you make a views exposed filter ?

  • Can you add a relationship to the view on the parent node to filter to the countries set on that node(s)?

  • Yes i used a views exposed filter. Interesting idea to use the relationship, but i found only the field Content: Location (field_location) and after add no more other fields. Maybe you can help me with the db_query function from the script. i don`t know where he get the iso variable.
    – Bruno
    Commented Nov 20, 2013 at 0:51
  • he gets it from the LEFT JOIN ... it is a default database column supplied from the Countries module. drupal.org/files/images/countries-admin.jpg
    – tenken
    Commented Nov 20, 2013 at 2:17
  • @Bruno Have you checked the field in views after adding relationship? Commented Nov 20, 2013 at 6:02
  • Ok, my fault! I use the Location module, not the countries module.
    – Bruno
    Commented Nov 20, 2013 at 11:59

I found a nice module collection called views hacks with "Views Selective Exposed Filters". It works very well and limit the list of countries, but now only the short names of countries will be shown.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.