Welcome Guest, Not a member yet? Register   Sign In
Crazzy query idea
#1

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


Messages In This Thread
Crazzy query idea - by El Forum - 07-16-2014, 09:52 AM
Crazzy query idea - by El Forum - 07-16-2014, 12:03 PM
Crazzy query idea - by El Forum - 07-16-2014, 01:09 PM
Crazzy query idea - by El Forum - 07-16-2014, 01:10 PM
Crazzy query idea - by El Forum - 07-16-2014, 04:08 PM



Theme © iAndrew 2016 - Forum software by © MyBB