douchong4730 2018-11-20 19:52
浏览 93
已采纳

Wordpress - 将联系表单7字段作为单独的列保存到数据库

I am using Contact Form 7 and Contact Form 7 Database Addon – CFDB7 to save values from my form to the database. The database plugin seems to work fine and saves information to the database, I am able to see all my fields in the WordPress dashboard in the format I would like however it saves all the fields and values in a "serialized" form.

enter code here a:17:{s:12:"cfdb7_status";s:4:"read";s:10:"user_login";s:5:"MyUser";s:4:"Date";s:10:"2018-11-20";s:10:"Name";s:3:"ABC";s:2:"BS";a:1:{i:0;s:1:"B";}s:3:"CMP";s:4:"1200";s:3:"CAB";a:1:{i:0;s:2:"CM";}s:2:"T1";s:3:"200";s:2:"T2";s:0:"";s:2:"T3";s:0:"";s:2:"SL";s:3:"150";s:8:"Calendar";a:1:{i:0;s:2:"TF";}s:8:"Period1C";s:0:"";s:8:"Period2C";s:0:"";s:2:"P1";s:1:"3";s:2:"P2";s:1:"6";s:8:"TimeType";a:1:{i:0;s:1:"M";}}

The CFDB7 plugin saves the above information in a separate table, however all the field data is saved in a single row. Is there a way or a plugin to save this information as separate columns in my table and all values under those columns. Something like this

User_login: MyUser Date: 2018-11-20 Name: ABC BS: B CMP: 1200 CAB: CM T1: 200 T2: 0 T3: 0 SL: 150 Calendar: TF Period1C: Period2C: P1: 3 P2: 6 TimeType: M

where User_login, Date, Name.... are all separate columns in the table and MyUser, 2018-11-20, ABC.... are the values under these columns for every entry.

Can you please advise how this can be done. The author of the plugin suggests to unserialize. I have read about unserialize but I was not able to do anything with it. I am familiar with SQL but not with PHP yet. I appreciate your help.

  • 写回答

1条回答 默认 最新

  • douwei1174 2019-01-17 22:42
    关注

    I was able to resolve this using Save Contact Form 7. I have been using it for about a month and have not encountered an issue.

    https://wordpress.org/plugins/save-contact-form-7/

    Edit: It is straightforward, you install the plugin, no configuration is required, it creates a custom table in the database with all the fields as separate columns. I have only used number type, text, radio button and dropdowns so far. Apparently, it also has the ability to save csv, pdf but I have never used it so can't tell how that works. I noticed that the plugin "hasn’t been tested with the latest 3 major releases of WordPress", however as of now it gets the job done.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵