I have a simple view (PEOPLE VIEW) based on a Form called PEOPLE.
Within the PEOPLE form there is unnormalised data: the form contains people and each may or may not have a SUPERVISOR assigned. Thus the same SUPERVISOR can appear on many people's entries.
I want to extract a simple list of the supervisors. In effect an SQL SELECT DISTINCT for the SUPERVISOR from the PEOPLE entries.
The view presently says (I have simplified by removing the HTML and other tests): [if 948 greater_than=""] [948] [/if 948] ---> where 948 is the field for the SUPERVISOR (I also sort the form by SUPERVISOR). This correctly lists SUPERVISORs but obviously names are duplicated since the same SUPERVISOR can appear on more than one entry. It is the equivalent of a simple SQL SELECT.
I can extract a CSV into Excel and remove the duplicates but it would be much better to be able to remove duplicates within Formidable.
I want to avoid PHP in this situation. Does anyone have any suggestions please?
Thank you, Michael.
By the way, because Formidable uses a metadata table design, all entry data is "unnormalized" by definition.
Ok, thanks Victor.
The shortcode/custom SQL is the option I would use.
However, I have not written SQL in a PHP shortcode and I do not know how the Formidable Forms forms/tables are structured.
Is there anywhere I could look for guidance on (a) writing SQL in PHP and (b) the FF table metadata table design structures?
I come from a long SQL background and do still struggle with unnormalised metadata.
All the best,
Michael.
Formidable's schema is here: https://formidableforms.com/knowledgebase/database-schema/
The SQL is "SELECT DISTINCT(meta_value) FROM `wp_frm_item_metas` WHERE `field_id` = '999' ORDER BY 1"
Change 999 to the field id for the field capturing the supervisor information.
Use the WordPress global $wpdb object to prepare and execute your SQL: https://developer.wordpress.org/reference/classes/wpdb/
Please login or Register to submit your answer