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

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 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀