[eluser]jedd[/eluser]
That wasn't me, you know. {points}
Hey, with the subtype being the ID in the form, how do you know what substrate you selected ..? Or do you simply not care? I'm assuming that subtype ID's can occur multiple times, under different substrate headings .. ? Or is that wrong.
You
could have both bits of data in your ID, you know, and split them later .. that's quite achievable, if you need to identify both substrate and subtype later, from the form selection.
The SQL that jwindhorst offered is pretty much what I was heading towards.
I tend to eschew the this->db->where/order/etc stuff still - far more comfortable with raw SQL calls.
IFF I have understood your schema properly, you might want to play with something like this (in the model)
Code:
$query = $this->db->query ("SELECT subtype.id AS subtype_id,
substrate.id AS substrate_id,
substrate.substrate AS substrate_name,
subtype.subtype AS subtype_name
FROM subtype
LEFT JOIN
substrate ON subtype.ssid=substrate.id
ORDER BY
subtype.subtype ASC");
$results = $query->result_array();
You might want to var_dump this, in your controller, to get an idea of what you are playing with. It will still need some massaging, of course, and this code is
not tested.