I just wanted some help figuring out how I would insert data that was coming out of a multiple select box, being put into a variable and then into a database.
My database table is structured like this - Table: prd_attr
ID | Product_ID | name | value
-------------------------------
1 | 3 | size | large
2 | 3 | size | medium
So say I have a multiple select box with the name sizes[], and the admin selects 2 sizes for a product to enter into the database. I can get these values in the controller and put them into a variable:
$sizes = $_GET['sizes'];
and pass that variable to the model. Once its there, I can insert the data as a MySQL query like this:
foreach ($sizes as $s)
{
$query = mysql_query("insert into prd_attr ('name', 'value') VALUES ('size','$s')");
}
But I've learned that mysql_* is deprecated, and since I'm using a framework which provides Active Records I'd like to make use of that. I know the basics of Active Record, but since this is a foreach loop over a variable which can hold any number of values, I don't know how to include a foreach statement with Active Records.
Could someone please explain?