zero_ZX Posted June 2, 2012 Share Posted June 2, 2012 Hi, I have a class that loops through a mysql table and then auto generates a form based on the table. It can ignore fields if there should be a need of that. Any way I would like to label the different inputs, provide descriptions etc, and would like to know an approach to this. What would you do in this case? I have a matching table containing settings where i could put a field and then it could contain a serialized array with the info, but not sure if there's a better alternative, please let me know Link to comment https://forums.phpfreaks.com/topic/263536-iterating/ Share on other sites More sharing options...
smoseley Posted June 2, 2012 Share Posted June 2, 2012 Do you have a db schema? Any code you can share? Link to comment https://forums.phpfreaks.com/topic/263536-iterating/#findComment-1350592 Share on other sites More sharing options...
zero_ZX Posted June 2, 2012 Author Share Posted June 2, 2012 No I do not have any code. The problem is not coding, more like designing. Link to comment https://forums.phpfreaks.com/topic/263536-iterating/#findComment-1350598 Share on other sites More sharing options...
smoseley Posted June 2, 2012 Share Posted June 2, 2012 The simplest way to do this is is with a single table: CREATE TABLE inputs ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `name` VARCHAR(255) NOT NULL, `type` ENUM('text', 'password', 'textarea', 'select', 'multiselect', 'checkbox', 'checklist', 'radiolist') NOT NULL DEFAULT 'text', `label` VARCHAR(255) NULL, `options` TEXT NULL ); Use `options` to store option values for "select", "multiselect", "checklist", and "radiolist" types. You can comma-delimit the field, then explode(",", $data['options']) in your php to retrieve an array of values. Link to comment https://forums.phpfreaks.com/topic/263536-iterating/#findComment-1350608 Share on other sites More sharing options...
zero_ZX Posted June 2, 2012 Author Share Posted June 2, 2012 Yea that would be for generating the for which i can already do. I want to describe the fields by adding a label, and it will be a mess to store labels together with the forms. Link to comment https://forums.phpfreaks.com/topic/263536-iterating/#findComment-1350612 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.