动态表单字段的创建和保存在数据库php mysql中
我正在制作医疗软件,但被困在某个地方.我必须创建一个报告部分,用户将在其中填写患者的报告.主要的收获是因为字段/列是可变的(少/多).说如果我在血液检查中填写表格,则列选项会有所不同,而X射线列会有所不同.
I am making a medical software and I am stuck at a point. I have to make a report section where user will fill up the reports for the patient. The main catch is since the fields/column is variable(less/more). Say if I fill up form in blood test, columns option are different and for X-ray columns is different.
我已经建立了一个数据库,因此它将存储该测试ID和患者ID的选项值
I have made a database so it will store option values for that test id and patient id
CREATE TABLE IF NOT EXISTS `mp_tests_options` (
`test_optn_id` int(11) NOT NULL AUTO_INCREMENT,
`optn_test_id` int(11) NOT NULL,
`optn_patient_id` int(11) NOT NULL,
`test_optn_name` varchar(255) NOT NULL,
`test_optn_value` LONGTEXT DEFAULT NULL,
`test_optn_def_value` LONGTEXT DEFAULT NULL,
PRIMARY KEY (`test_optn_id`),
INDEX (`optn_test_id`),
INDEX (`optn_patient_id`),
FOREIGN KEY (optn_test_id) REFERENCES mp_tests(test_id)
ON UPDATE CASCADE ON DELETE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;
但是我如何通过适当的验证使用户成为前端.我不想单独写每个表格.
But how do i make the front end for user with proper validation. I dont want to write each form individually.
感谢您的时间.
为所需的每种表格中的哪些列创建一个单独的表.
Create a separate table for what columns are required in every form you want.
_______________________________________________
| formName | fields |
|-----------------------------------------------|
| x-ray |field1,field2,field3,field4 |
|-----------------------------------------------|
| bloodtest |field1,field2,field3,field4 |
|_______________________________________________|
然后使用explode()将其转换为数组.还创建一个表,其中包含每个表单名称的可能字段.只需在不需要的字段中插入空白即可.
And then use explode() it to convert it to array. Also create a table that has possible fields to every form names. Just insert a blank to unneeded fields.