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 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。
  • ¥20 CST怎么把天线放在座椅环境中并仿真
  • ¥15 任务A:大数据平台搭建(容器环境)怎么做呢?
  • ¥15 YOLOv8obb获取边框坐标时报错AttributeError: 'NoneType' object has no attribute 'xywhr'