I have been working on this for the past 4 hours, with problem after problem. Now that I have finally come to the end of most of my problems, I can't seem to get a solution to the final problem.
Problem: I have to send out an email to a student (email is stored in DB). In the email there has to be an un-ordered list with list items. That part was the easy part (html email). The problem that I am now facing is that I want to get the actual name of the form, not the value because the value is just
value="1" value="2"
That won't provide the student with much info to what the forms are.
These are my input fields:
<label id="form"><input type="checkbox" name="form[]" value="3" >DECSP</label>
<label id="form"><input type="checkbox" name="form[]" value="4" >DESNAP</label>
If you notice the value again is just a number, I want to actually get the NAME of the form which DESCP and DESNAP
This is what I tried:
$body .= '<ul>';
$forms = $this->input->post('form'); // The check boxes
$dbforms = $this->queue_model->first10() + $this->queue_model->elev9() + $this->queue_model->twenty_5() + $this->queue_model->twen8thir7() + $this->queue_model->checklists(); // Here I take the forms from the database and combine the arrays
$givenforms = array_intersect_assoc($dbforms, $forms); // Here I do an intersect where form_id matches the value
foreach ( $givenforms as $key => $value) { // If a match is good then give me the form_name
$body .= '<li>' . $value . '</li>';
}
$body .= '</ul>';
I am quite confused as to where to go from here. Hopefully you guys understand.
The only thing I can possibly think of is to do a
foreach
loop over all the forms that where checked in the check boxes, then in a query
select * forms where form_id = (what form was checked)
then
return
the actual name of the form.
But again, I do not know if this would be a proper solution. Thanks in advance for any information that you guys could pass along.
Edit 1 :
The check boxes have to be an array so that I can store in the database which forms a student received. Take a look at my other question.