[eluser]Atrhick[/eluser]
Hello guys, I'm not a very good programmer so this maybe very simple but I'm going to ask anyhow.
here is what I need to do
I'm collecting this data from the view using post.
Code:
function add_test() {
$test_title = $this->input->post('test_title');
$test_creator = $this->input->post('test_creator');
$test_created = $this->input->post('test_created');
$this->db->escape($test_title);
$this->db->escape($test_creator);
$this->db->escape($test_created);
//Question #1
$question_1 = $this->input->post('question_1');
$answer_1_question_1 = $this->input->post('answer_1_question_1');
$answer_2_question_1 = $this->input->post('answer_2_question_1');
$answer_3_question_1 = $this->input->post('answer_3_question_1');
$answer_4_question_1 = $this->input->post('answer_4_question_1');
$answer_5_question_1 = $this->input->post('answer_5_question_1');
$this->db->escape($question_1);
$this->db->escape($answer_1_question_1);
$this->db->escape($answer_2_question_1);
$this->db->escape($answer_3_question_1);
$this->db->escape($answer_4_question_1);
$this->db->escape($answer_5_question_1);
$data = array(
'test_title' => $this->input->post('test_title'),
'test_creator' => $this->input->post('test_creator'),
'question_1' => $this->input->post('question_1'),
'answer_1_question_1' => $this->input->post('answer_1_question_1'),
'answer_2_question_1' => $this->input->post('answer_2_question_1'),
'answer_3_question_1' => $this->input->post('answer_3_question_1'),
'answer_4_question_1' => $this->input->post('answer_4_question_1'),
'answer_5_question_1' => $this->input->post('answer_5_question_1'),
'test_created' => $this->input->post('test_created')
);
$this->db->insert('tests',$data);
}
My problem is the when the user is creating a test they can create 350 questions in one test "yes the database can hold all that data in one table row" is there a loop i can create or something that will do what i have above based on how much data in coming in?
I don't this its good coding practice for me to do the above code 350 time... or do I have to?