CodeIgniter Forums
Need a little guidance. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Need a little guidance. (/showthread.php?tid=37971)



Need a little guidance. - El Forum - 01-26-2011

[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?


Need a little guidance. - El Forum - 01-26-2011

[eluser]BrianJM[/eluser]
Have you looked at the tutorials?