如何生成反映MySQL表的FORM? [英] How to generate FORM that reflects MySQL table?

查看:40
本文介绍了如何生成反映MySQL表的FORM?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据 MySQL 表字段生成 HTML 表单.生成的输入应反映 MySQL 列的类型,例如VARCHAR = 文本、TEXT = 文本区域、ENUM = 复选框、SET = 单选等

I want to generate HTML form based on MySQL table field. The generated input should reflect the type of the MySQL column, e.g. VARCHAR = text, TEXT = textarea, ENUM = checkbox, SET = radio, etc.

推荐答案

这是一个两步问题.

  1. 首先您需要分析数据库表.您可以使用 SHOW 获取列名、类型等列.
  2. 您需要根据检索到的信息生成表单.

生成表单可以像迭代从 SHOW COLUMNS 查询接收到的数组并在迭代过程中构建 HTML 一样简单,或者使用现有的表单生成库,例如Zend_Form朵拉.

Generating form can be as simple as iterating the array received from SHOW COLUMNS query and building HTML along the iteration, or using existing form generation libraries, e.g. Zend_Form or Dora.

根据您的需要,现有软件可用于反映和操作整个数据库,例如phpMyAdmin.此外,一些框架提供了以 CRUD 操作的形式反映整个模型(即数据库表)的方法,例如Symfony 表单.

Depending on your needs, there is existing software for reflecting and manipulating the whole database, e.g. phpMyAdmin. Furthermore, some frameworks provide means of reflecting the whole model (i.e. database table) in a form for CRUD operations, e.g. Symfony Forms.

这篇关于如何生成反映MySQL表的FORM?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆