Form to Database in one row
-
The plugin creates multiple rows for each entry. Is there anyway to make this plugin create one row per contact form with the columns being the field names of the contact form?
Thanks in advance!!
Same question:
https://wordpress.org/support/topic/plugin-contact-form-7-to-database-extension-form-to-database-in-one-row?replies=1https://wordpress.org/plugins/contact-form-7-to-database-extension/
-
I already tried with this:
http://cfdbplugin.com/?page_id=239but I’d like that plugin automatically saves info like that…
You can create a View in the DB like the link you cited says so that it looks like a table.
Alternately, you could hook in some code to write the form data to your own table. Refer to Changing Data Before it is Saved but instead of changing it, you would put in the code to save to your table.
And if you want to know why things are set up this way, read this.
I read all the links you give me before asking the question and I tried to make some changes but without success..
Can you gently give me a simple template set for example name, email and date as colums and put all the data in a single row?
Thanks in advance Michael.
[ No bumping please. ]
I was hoping for more info. What are the field types? Is this a multipart form? How does it integrate with PayPal? Are they any special settings?
It doesn’t integrate Paypal.
There are two different types of Contact Form.The first type has these fields:
[text* nome watermark "Nome e Cognome"] [text* indirizzo watermark "Indirizzo"] [text* cap watermark "CAP"] [text* provincia watermark "Provincia"] [email* email watermark "E-mail"] [tel telefono watermark "Telefono"] [textarea messaggio watermark "Messaggio"] Accetta i Termini di servizio [acceptance privacy] [submit "Invia"]</p>and the second one has these fields:
[text* nome watermark "Nome e Cognome"] [email* email watermark "E-mail"] [tel telefono watermark "Telefono"] Accetta i Termini di servizio [acceptance privacy] [submit "Invia"]</p>Sorry, I replied to the wrong thread here (hence the PayPal reference).
I’m not clear on if you are trying to make a View or to save the form submissions into your own table.
I already created a View, but I’d like to save form submissions in a different way as it saves right now.
I’d like to create one row per contact form with field names as columns
The View I created:
SELECT
submit_timeAS ‘Submitted’,
max(if(field_name=’nome’,field_value, null )) AS ‘nome’,
max(if(field_name=’indirizzo’,field_value, null )) AS ‘indirizzo’,
max(if(field_name=’cap’,field_value, null )) AS ‘cap’,
max(if(field_name=’provincia’,field_value, null )) AS ‘provincia’,
max(if(field_name=’email’,field_value, null )) AS ’email’,
max(if(field_name=’telefono’,field_value, null )) AS ‘telefono’,
max(if(field_name=’messaggio’,field_value, null )) AS ‘messaggio’,
max(if(field_name=’privacy’,field_value, null )) AS ‘privacy’,
max(if(field_name=’tipo’,field_value, null )) AS ‘tipo’,
max(if(field_name=’Submitted Login’,field_value, null )) AS ‘Submitted Login’,
max(if(field_name=’Submitted From’,field_value, null )) AS ‘Submitted From’,
GROUP_CONCAT(if(fileis null or length(file) = 0, null,field_name)) AS ‘fields_with_file’
FROMwp_cf7dbplugin_submits
WHEREform_name= ‘Contact1’
GROUP BYsubmit_time
ORDER BYsubmit_timeDESC
LIMIT 0,100I’d like to save forms on the db like this view.
Create a table in your database with the fields you want.
Referencing Changing Form Data Before it is Saved, in your “myfilter” function (or whatever you name it), you need to insert the information into your table.
declare:
global $wpdb;
then you basically want to call $wpdb->insert( $table, $data, $format ); where you can pass in $formData->posted_data for $data. Those are all string values, so if your DB table has other types like int, then you will have to convert them and use the $format variable. (refer to $wpdb documentation).Can you gently post here a simple template/example so I can start with it?
Thanks in advance
I don’t have any.
I can’t fully understand your previous post, can you gently tell me full steps?
Sorry for the inconvenience Michael.
[ No bumping please. ]
I’ve outlined what you need to do. But it’s up to you to write your own code. You may find that you need help from someone with more knowledge of PHP & WP to create the code.
Michael, is it possible to extract data from a view? Can be considered a table?
Yes, query it as if it were a table. But you cannot update data in it
The topic ‘Form to Database in one row’ is closed to new replies.