Help in populating form with MySQL query values
-
Hi everyone,
I have been using WordPress for quite a while but I never really “programmed” in it. I tried googling my question but never got any clear answer about my needs.
Here’s the situation :
I have a database table in my WordPress database that is homemade and contains customer license keys with informations like the name of the owner, the name of the reseller, the address and the different modules he owns on his license key.
I am using WooCommerce with “WooCommerce Product Add-Ons” as well as “Ninja Forms”.
What I need to do is :
I must be able to query the database table and fetch a key’s information and, with this, populate either “Product Add-Ons” fields or, if this ain’t possible, a “Ninja Forms”.
I found out that if I put this in my template’s functions.php :
function my_filter_function( $data, $field_id ){ if( $field_id == 18 ){ $data['default_value'] = 'Quebec'; } if( $field_id == 10 ){ $data['default_value'] = '1'; } return $data; } add_filter( 'ninja_forms_field', 'my_filter_function', 10, 2 );
It will put “Quebec” in my Field 17 which is “Province” in my form and “1” in Field 10 puts a checkmark in a field with a checkbox.
So now, what I need to do is put this query somewhere :
SELECT keylic, keycie, keyci2, keyaddr, keyCity, keyProv, KeyPC, KeyPhone FROM wp_licensekey WHERE keylic = "input value from a form field"
And populate the form with this kind of command :
if( $field_id == 18 ){ $data['default_value'] = '>>Value should be set here<<';
Thanks for your help ??
- The topic ‘Help in populating form with MySQL query values’ is closed to new replies.