Jump to content

MySql Base help - Codeigniter


skemi90
Go to solution Solved by Muddy_Funster,

Recommended Posts

Hello,

 

I am new to php and I am stuck with this problem.

I have in my mysql base a table (table1) with three columns A, B and C (for easy explanation).

 

 id   A      B        C

 1   60    200     4

 2   40    100     3

 ...  ...      ...       ...

Table has more than 500 combinations.

 

I created two input fields on my index page for column A and B. C column is a result.

 

Problem is to code next:

When someone enters 60 and 200 in those two input fields I want to generate an automatic result 4, for 40 and 100 result 3 and so on.

 

I am using codeigniter framework. If it is needed you can split above table to three tables A, B and C.

Thanks in advance and sorry for my bad english,

please don't hesitate to ask questions.

Link to comment
Share on other sites

Model 

    public function GET($input1, $input2){

        $this->db->select('c');
        $this->db->from('table1');
        $this->db->where('A', $input1);
        $this->db->where('B', $input2);

        $query = $this->db->get();
        return $query;
    }

Controller

public function get_result()
    {
        //validation rules

        $this->form_validation->set_rules('a', 'A', 'trim|required');
        $this->form_validation->set_rules('b', 'B', 'trim|required');

        if ($this->form_validation->run() == FALSE) {

            $this->load->view('admin/dashboard/inc/header');
            $this->load->view('admin/procena/index');
            $this->load->view('admin/dashboard/inc/footer');
        } else {

            $input1 = $this->input->post('A');
            $input2 = $this->input->post('B');

                $result = $this->ModelABC_model->GET($input1,$input2);
                echo $result;

                /*redirect('admin/index');*/

        }
    }
At least now I'm going in a certain direction, I think I understand your logic but now I have a new problem. 
 

I get an error "could not be converted to string"

 

Thank you for your rapid response.

Link to comment
Share on other sites

This topic is SOLVED!

 

I was loking a way to mark it by myself, but without luck.  ::)

 

Please, can any moderator mark this topic as SOLVED?

There is a "Mark Solved" button on the lower-right of each post. Click that next to the post that was most helpful.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.