by singersoll » Wed Sep 26, 2007 6:10 am
I tried using the inspection_items field but it only worked for one field in my inspection table. What I really need is to show all the fields in this table in my inspection "Form" and have the inspector select the default value or 0.
The items in the inspection_items table are constant and will not change.
I found another way so opted to have all my fields in my inspection table and use enum to use one value or the other and default to the normal value. The example is that 02 would correspond to 'item_name' in my inspection_items table.
`02` enum('0','5') NOT NULL default '5',
If there is a better way to do this I would appreciate the input.
Also, how do I do about selecting certain values in the inspection table and have the sum populate the results field? As an example -> fields 01 and 02 would have a total of 9 if the default was used.
CREATE TABLE `inspection` (
`id` int(11) NOT NULL auto_increment,
`inspector_name` varchar(32) NOT NULL default '',
`categories` varchar(32) default NULL,
`permits_number` int(4) default NULL,
`purpose` enum('Complaint','Follow-up','Investigation','Regular','Other') NOT NULL efault 'Regular',
`establishment` varchar(64) NOT NULL default '',
`owner` varchar(64) NOT NULL default '',
`charge` varchar(64) NOT NULL default '',
`address` varchar(64) NOT NULL default '',
`zips_name` varchar(64) default NULL,
`zips_zip` varchar(5) NOT NULL default '',
`01` enum('0','5') NOT NULL default '4',
`02` enum('0','5') NOT NULL default '5',
`results` int(11) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
Sorry that I am short on the DBA side of the house and appreciate any input.
TIA,
Steve