[eluser]Unknown[/eluser]
So I'm trying to break my procedural only coding habits. As a first step into OOP I decided to build an application with code igniter.
I have Two tables:
Table "Books" has:
ID | name | author
Table "genres" has:
ID | book_id | genre
My form looks like this:
Code:
<form>
<input name="cats[]" value="1" type="checkbox">
<input name="cats[]" value="2" type="checkbox">
<input name="cats[]" value="3" type="checkbox">
<input name="cats[]" value="4" type="checkbox">
<input name="cats[]" value="5" type="checkbox">
<input name="bookid" type="hidden" value="<?php echo $bookid; ?>">
</form>
So The user clicks "add" and the query does this:
Code:
$cats = $_POST['cats'];
// Add Genres
foreach($cats as $cat_ids) {
$insert_data = "INSERT INTO ecms_book_cat_assoc VALUES (NULL, '$bookid', '$cat_ids')";
mysql_query($insert_data) or die ( mysql_error() );
}
What I'm confused on is, how do i do this same thing within a model within the code igniter frame work?