Multiple-choice list box from table

Got something cool to share with AppGini users? Feel free to post it here!
Post Reply
User avatar
baudwalker
Veteran Member
Posts: 188
Joined: 2015-02-03 08:08
Location: Bellingen NSW Australia

Multiple-choice list box from table

Post by baudwalker » 2020-02-13 09:00

Is the a way to set up a Multiple-choice list box, similar to what is available in the options list, but the selections are from a table field in stead of using the options list?

G Belgrado
Veteran Member
Posts: 61
Joined: 2017-03-12 09:24

Re: Multiple-choice list box from table

Post by G Belgrado » 2020-02-13 10:06

Yes, this page https://bigprof.com/blog/appgini/a-work ... gini-apps/
describes how to create a selection from table data

User avatar
baudwalker
Veteran Member
Posts: 188
Joined: 2015-02-03 08:08
Location: Bellingen NSW Australia

Re: Multiple-choice list box from table

Post by baudwalker » 2020-02-13 22:05

Thank you for point this out I will see if it can be implemented in my situation

User avatar
baudwalker
Veteran Member
Posts: 188
Joined: 2015-02-03 08:08
Location: Bellingen NSW Australia

Re: Multiple-choice list box from table

Post by baudwalker » 2021-01-30 03:48

This has been working fine, but now I have another project that I wish to populate multi-choice list by adding records to the table but with a further twist.

Each user will have a different list created by their own table entries. I would require something like {tablename}.{fieldname}.{user}.csv. can this be done?

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

Re: Multiple-choice list box from table

Post by onoehring » 2021-01-30 16:25

Hi baudwalker,

I think I have a similar problem described here ( viewtopic.php?f=2&t=4098 ) - but have not gotten any solution so far.
There is some possibility I am considering at this time which I will describe in a second.
Some ideas first:

a) Why not follow the idea pbötcher's link (to the blog) holds, but extend the 'tags' table by another column 'customer'. Depending on how busy your table is, you might pull only those 'tags' from that table that match the customer and write those to the file.

b) You should take a look at the AG functions that are looking for that csv on your server. Probably it should be quite easy to change that function to use the name-extension you are suggesting. One drawback: That function will probably be overwritten when you regenerate your app in AG.
A quick check on one of my applications shows that this seems to be in the (not hooks directory) /tablename_dml.php file. Look for the function

Code: Select all

function YourTablename_form(
There you find something like

Code: Select all

if(is_file(dirname(__FILE__).'/hooks/YourTablename.YourFieldName.csv')) {
$YourFieldName_data = addslashes(implode('', @file(dirname(__FILE__).'/hooks/YourTablename.YourFieldName.csv')));
You should be able to apply your suggestion there, something like this:

Code: Select all

if(is_file(dirname(__FILE__).'/hooks/YourTablename.YourFieldName.csv')) {
$mi = getMemberInfo();
$username = $mi['username'];
$YourFieldName_data = addslashes(implode('', @file(dirname(__FILE__).'/hooks/YourTablename.YourFieldName.' . $username  . '.csv')));
Remember: The file will be overwritten when the app is being recreated.



.... well, so only theory, not tested!

Olaf

User avatar
baudwalker
Veteran Member
Posts: 188
Joined: 2015-02-03 08:08
Location: Bellingen NSW Australia

Re: Multiple-choice list box from table

Post by baudwalker » 2021-02-01 04:06

Thank you Olaf

That looks like what I require.

The database is very active on certain day with about 1000 users. Each may have their own .csv file.

I will have a go at you idea in a few days and see how I go.

Barry

Post Reply