1. jameswadsworth
  2. Support
  3. Sunday, June 23 2019, 08:16 PM
With Easy Profile Select list there is the option to set DB params to get information from a table. Great feature. However we are struggling to understand how the filter database options based on the value of this field works.

We have 2 tables. One that contains a list of countries. The second table contains a list of states. We have created 2 select lists, one for the counties, one for the states. We'd like to be able filter the states in the select list according to the country selected in country list. Is this possible?
Accepted Answer
admin Accepted Answer
Admin
Hi,
unfortunately Select DB feature does not manage something like this, anyway there is a workaround: you can create a view in your database for states:
- Open a tool to manage your database like phpMyAdmin, normally something like this is provided by your hosting provider.
- Launch a query like:
CREATE ALGORITHM = UNDEFINED VIEW `states` AS SELECT a.*,b.zone_parent_namekey FROM bmc9r_hikashop_zone as a,bmc9r_hikashop_zone_link as b WHERE a.zone_namekey = b.zone_child_namekey AND a.zone_type="state";

This will create a dynamic table that contain only states and with columns like #__hikashop_zone plus one more column called "zone_parent_namekey" from table #__hikashop_zone_link
- Now configure your fields like screenshots
Attachments (2)
  1. more than a month ago
  2. Support
  3. # Permalink
admin Accepted Answer
Admin
Hi,
sorry for late reply, it was a weekend :D

Yes, this is possible, I suppose you have a tables structure like this:
Table Countries "countries":
country_id (ID of the country)
country_name (Name of the country)

Table States "states"
state_id (ID of the state)
state_name (Name of the state)
country_id (ID of the country associated)

So you need to create 2 select fields, Country and States, and fill options like screenshot.
Attachments (2)
  1. more than a month ago
  2. Support
  3. # 1
jameswadsworth Accepted Answer
Thanks for the reply. We have hikashop installed on the site and we are wanting to get the data from the table #__hikashop_zone. For the list of countries it works fine. However to list the states some information is in another table #-_hikashop_zone_link and requires a left join.

Is it possible with a bit of messing around to get this working?

Thanks
  1. more than a month ago
  2. Support
  3. # 2
jameswadsworth Accepted Answer
Content Protected
  1. more than a month ago
  2. Support
  3. # 3
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.