Relating two tables
-
Howdy.
Ok, I’m very new to this plugin, so not quite sure of the best approach to this. Any pointers would be greatly appreciated.
I have two tables created as follows:
CREATE TABLE
svs_seed_type`
(seed_type_id
int(20) NOT NULL auto_increment
,seed_type_name
varchar(32) NOT NULL DEFAULT ”NULL”
,seed_type_season_warm
tinyint(1) NULL DEFAULT NULL
,seed_type_popup_id
int(20) NULL DEFAULT 0
,PRIMARY KEY (seed_type_id
)
) ENGINE InnoDB DEFAULT CHARACTER SET utf8 COLLATE=utf8_general_ci;
CREATE UNIQUE INDEXseed_type_name
ONsvs_seed_type
(seed_type_name
);`CREATE TABLE
svs_seed_item`
(seed_item_id
int(20) NOT NULL auto_increment
,seed_item_photo
varchar(256) NULL DEFAULT ‘NULL’
,seed_item_variety
varchar(128) NULL DEFAULT ”NULL”
,seed_item_ref
varchar(128) NULL DEFAULT ‘NULL’
,seed_item_extras
tinytext NULL DEFAULT ‘NULL’
,seed_item_type_id
int(20) NOT NULL
,PRIMARY KEY (seed_item_id
)
) ENGINE InnoDB DEFAULT CHARACTER SET utf8 COLLATE=utf8_general_ci;
CREATE INDEXseed_type
ONsvs_seed_item
(seed_item_type_id
);`It is the type field where I have questions.
First, in the form used to enter a new seed item I wish to have a pulldown containing the names of the types, from which the administrator can select.
Second, in the page presenting the available seed items to the end user, I would like to be able to set the color of the type name based on whether seed_type_season_warm is 0 (so blue) or 1 (so red).
How best to do something like this? Views? (If there’s something I should read / look at, I’d appreciate getting pointed in that direction…).
Thanks so much!
- The topic ‘Relating two tables’ is closed to new replies.