Forums

Join two tables, result in one dropdown

jpurlings 08 Dec, 2016
Bob,

I want to join 2 tables using the relations options in DB Read and have the resulting rows of three columns as separate lines in one dropdown box.

Your credentials of my site are still the same. The form in which I try to do it is called 'BusinessModelCoach'. In the first DB Read I try to organise it. With the Debugger I can see that the query for the join is correct. But I can't get the data in the dropdown. I am probably doing something wrong in the conditions of the DB Read...

Could you help me with this?

Thanks!
GreyHead 08 Dec, 2016
Hi jspurlings,

I get: Warning - You do not have access to the Administrator section of this site.

Can you post the Debugger output? There isn't enough here to get a clue about what is happening.

Bob
jpurlings 08 Dec, 2016
Hi,

Sorry, I changed the user group. Now you should be able to enter the site.

Greetings.
jpurlings 09 Dec, 2016
Bob,

I hope you are able to log in?

Greetings.
GreyHead 09 Dec, 2016
Hi jpurlings,

Yes, I can log in now thank you. But how do I get the form to show? At present it just gives an error screen - probably because I don't have anything in $form->data['Users']??

Bob
jpurlings 10 Dec, 2016
Bob,

I tried with your credentials, it works at my side. Did you look at the form BusinessModelCoach?

Greetings.
jpurlings 10 Dec, 2016
Bob,

By the way. The form is not connected to a menu yet. I use the 'Test form' option in Chronoforms to test the form.

Greetings.
GreyHead 11 Dec, 2016
Hi jpurlings,

I was able to access the site briefly and take a look - then I just get timeout errors :-(

I can see some data there - but some of it is blank - and I'm not clear what you mean by "have the resulting rows of three columns as separate lines in one dropdown box" ??

Bob
jpurlings 11 Dec, 2016
Hi Bob,

Strange, I tried it again with your credentials, at my side I don't get timeout errors...

What I mean is that I want to do a left join of two tables: the table with user info of the component Easy Social and the table of the form BusinessModel. I want info of three columns (two from the user table and one from the form table) of all the users in a dropdown box. The query that is generated by the Read DB event, using the relations tab, with the join statement is correct. But I get the impression that the query is not executed, because I don't see the resulting data in the debugger. And if I have the data, I should have them in an array so that I can pass them to the dropdown box. I don't know how to do this...?

Greetings.
GreyHead 11 Dec, 2016
Hi jpurlings,

Will try again tomorrow.

I could see the data output from the query OK - though the structure wasn't too helpful.

I still don't get what you mean by "info of three columns . . . in a dropdown box" - a dropdown option has two parts - a value (which is submitted) and a text (which is displayed). How exactly do the three columns get added?

Bob
jpurlings 12 Dec, 2016
Hi Bob,

You are right, the part about the three columns in the dropdown box is not clear. I want to concatenate the three text strings from three columns to be put in one line of the dropdown box as one string. There are multiple rows in the database that need to be loaded into the dropdown box that way (by using a query with a join statement, using the relations tab of the DB read event).

Greetings.
jpurlings 12 Dec, 2016
Bob,

Just to let you know. I am installing aan SSL certificate on my site. Having some problems with it, so you could get a security warning. You can just proceed to the site, the warning concerns the problems with SSL, it poses no risk whatsoever.

Greetings.
GreyHead 12 Dec, 2016
Hi jpurlings,

I've tried several times this morning but can't access the site at all from here.
This site can’t be reached

www.bizzaccelerator.biz took too long to respond.
Search Google for biz accelerator index
ERR_CONNECTION_TIMED_OUT

Bob
jpurlings 12 Dec, 2016
Bob,

I will look into it.

Meanwhile, is there somewhere a description / manual of how the relationstab of DB Read works, and how to get the results of a join of two tables via the relationstab in the form / dropdown box? I have looked for it, but can't find it.

Greetings.
GreyHead 12 Dec, 2016
HI jspurlings,

Still not visible, if you post the Debugger output I'll give you some custom code to merge the column info,

Bob
jpurlings 12 Dec, 2016
Bob,

Debugger output is attached.

Security problem with the site is resolved, maybe it works for you now?

I will take a faster hosting plan, not a good sign for my site that you have those troubles. But it take some time until the new plan is up and running.

Hope you can help me with your code!

Thanks!
GreyHead 13 Dec, 2016
Hi jspurling,

I can access OK this morning - thank you

I've made a copy of your form and replaced the DB Read with a Custom Code action that loads the merged data and the concatenated values (as $form->data['option'] ). It't a bit tricky as there are no matching values in the BMS table at the moment. You may well need to edit the query to get exactly what you want.

Bob

PS I installed the MijoSQL extension to see the DB tables clearly - I suggest that you disable or uninstall when you are finished developing.
jpurlings 13 Dec, 2016
Bob,

Great! I altered the query. That works. Then I populated the dropdown with the array, but it doesn't show all the rows from the query. It seems to show n-1 rows...? What am I doing wrong?

Greetings.
GreyHead 13 Dec, 2016
Answer
Hi jpurlings,

That was because there is no matching BMS entry for the third record, I've added an IFNULL() statement to the MySQL to set the value to 999 in that case; now you see all three options - but that may not be the best solution for what you need to do.

Bob
jpurlings 13 Dec, 2016
Great!

Thanks, that works now!
This topic is locked and no more replies can be posted.