Skip to Content Skip to Menu

[SOLVED] Trying to create a drop down with query field

  • fribse2011
  • fribse2011
  • OFFLINE
  • Posts: 921
  • Thanks: 79
  • Karma: 8
9 years 11 months ago - 9 years 11 months ago #253940 by fribse2011
Versions are: J2.5.27, CB 2.0.3, Core Ajax 2.0.0

I have a list of zipcodes with cities.
It's imported in my DB as
kef_postnumre
But if I activate the field I get a 'SQL query' error shown.
The tabs in the query fields are:








What did I do wrong? I think I followed the example shown with the country list.

Best regards
Fribse

Frømandsklubben Nikon, www.nikondyk.dk
We're a volunteer driven diving club in Ishøj, Denmark.
Har du brug for en dykkerklub der rummer alle, så kom ned til os.
Attachments:
Last edit: 9 years 11 months ago by fribse2011.

Please Log in or Create an account to join the conversation.

  • fribse2011
  • fribse2011
  • OFFLINE
  • Posts: 921
  • Thanks: 79
  • Karma: 8
9 years 11 months ago #253942 by fribse2011
Replied by fribse2011 on topic Trying to create a drop down with query field
Ahh, the city is called 'by' in danish, so using that in the order statement gives me problems.
I've removed the 'by', and now I don't get an error, though I don't get the right info either.
I've removed the 'by' from the label fields.
So now I get a list of zip codes.
Is it possible to get both the zip and the city shown in the dropdown list?
Is it possible to have both values stored in the cb field? (I currently have a delimiter field doing the presentation of the two fields combined, but maybe that could be saved)

Best regards
Fribse

Frømandsklubben Nikon, www.nikondyk.dk
We're a volunteer driven diving club in Ishøj, Denmark.
Har du brug for en dykkerklub der rummer alle, så kom ned til os.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48501
  • Thanks: 8284
  • Karma: 1443
9 years 11 months ago #253964 by krileon
Replied by krileon on topic Trying to create a drop down with query field

Is it possible to get both the zip and the city shown in the dropdown list?

You can get whatever information you want. Your query just needs to be correct. Test your query against your database directly using phpmyadmin (replace #__ prefix as needed for this) then see what the results are. CB Query Field will see the exact same results. For example if you need the label to contain more information then you'd CONCAT them in your query. Example as follows.

CONCAT( `field1`, `field2` ) AS label

Is it possible to have both values stored in the cb field? (I currently have a delimiter field doing the presentation of the two fields combined, but maybe that could be saved)

CB Query Select fieldtypes do store their values in the database like a normal select fieldtype. The only difference is the options come from a query.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • fribse2011
  • fribse2011
  • OFFLINE
  • Posts: 921
  • Thanks: 79
  • Karma: 8
9 years 11 months ago #253973 by fribse2011
Replied by fribse2011 on topic Trying to create a drop down with query field
Ahaa, I see, thanks, that made it work. Now I need to get some time to transfer the field that only contains the zipcode to a field that contains both zip and city, but it's way cooler this way I think, thankyou!

Best regards
Fribse

Frømandsklubben Nikon, www.nikondyk.dk
We're a volunteer driven diving club in Ishøj, Denmark.
Har du brug for en dykkerklub der rummer alle, så kom ned til os.

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum