Welcome Guest, Not a member yet? Register   Sign In
Checkboxes - What is the process
#1

[eluser]Samuurai[/eluser]
Hi,

I've used CI for quite a while, but the database side of things is not (yet) my strong point!!

I've got all my checkboxes set up like this:
Code:
<input type="checkbox" class="checkbox"  name="skills[]" value="Hospitality" <?=set_checkbox('skills[]','hospitality')?> />
<label class="chkbox_label">Hospitality</label>
&lt;input type="checkbox" class="checkbox"  name="skills[]" value="Promo Girl"&lt;?=set_checkbox('skills[]','promo_girl')?&gt; /&gt;
<label class="chkbox_label">Promo Girl</label>

I then have a table, Skills, which has the id and name of the skills (the name is the same as the value= in the form input attributes.

I then want to insert the Userid - I got that ok using db->insert_id() - and the skills into a table called User_Skills which has the User_id and Skill_id

I am unclear on what I should really have in my input value.. should this be the id so I can then insert that straight into User_Skills? Or should I do
Code:
foreach ($skills as $skill) {
//pseudo code
$skill_id = SELECT id FROM Skills WHERE name = $skill;
INSERT into User_Skills User_id, Skill_id VALUES ($User_id, $Skill_ID)
}
- Just seems like a lot of looping and database calls. - I'm sure there's any easier way and i'd be very appreciative if one of you seasoned pro's could point it out to me.

Thanks!
#2

[eluser]Samuurai[/eluser]
Bump (!) Smile




Theme © iAndrew 2016 - Forum software by © MyBB