drop down list by MySQL Table , but only per user record

4 posts by 2 authors in: Forums > CMS Builder
Last Post: February 6, 2009   (RSS)

Re: [guido_ch] drop down list by MySQL Table , but only per user record

By Dave - February 6, 2009

Hi Guido, welcome to the CMS Builder forum! :)

This isn't supported by the software but it is possible with some custom MySQL and PHP.

In the field editor you probably have your list field set to "Get options from database" followed by tableName, valueField, labelField (of course you'll have values selected for those).

What you want to do is change that to "Get options from MySQL query" and enter this:

SELECT valueField, labelField, FROM <?php echo $TABLE_PREFIX ?>tableName WHERE createdByUserNum = '<?php echo $GLOBALS['CURRENT_USER']['num'] ?>'

And replace the red fields with the actual names of your fields and table. What this does is load the same values but only return records that are created by the user who is currently logged in.

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] drop down list by MySQL Table , but only per user record

Wow this was fast! Thank you very much!
Is there some documentation, where all these global-variables (like CURRENT_USER) are listed?

Cheers
Guido

Re: [guido_ch] drop down list by MySQL Table , but only per user record

By Dave - February 6, 2009

No, there's not many of them that would be useful and those are the internals of how the program works so they can change (that one won't though).

When people ask though we often try to find a solution and sometimes that means digging into the code.

If you have another challenge that might require an internal value feel free to ask and we'll provide it if we can.
Dave Edis - Senior Developer
interactivetools.com