Welcome Guest, Not a member yet? Register   Sign In
Using results from one query to serch in a new query
#1

[eluser]The Revel[/eluser]
I am lost, I cannot figure out how to use the results from one query to grab the info from another query.

Here is the function:

Code:
function search_scancode()
    {
        
         $q1 = $this->db->from('users')
            ->where('scancode', $_POST['searchcode'])
            ->get();
         if ($q1->num_rows() > 0)
            {
            $this->data['user'] = $q1->row();
            }
        $q2 = $this->db->select('SUM(amount) as sum_amount', FALSE)
            ->from('transactions')
            ->where('email', $this->data['user']->email)
            ->group_by('email')
            ->get();
            if ($q2->num_rows() > 0)
            {
             $this->data['sum'] = $q2->row()->sum_amount;  
            }    
         $this->template
            ->title( 'Last Minute Printing', 'Print Card')
            ->set_layout('login')
            ->build('auth/scan_view', $this->data);
I get nothing but errors when I try and view the page. The first of which is
Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined property: Auth::$data
Filename: controllers/auth.php
Line Number: 640
Which points to this line
Code:
->where('email', $this->data['user']->email)

How do I pass results from one query into another?
#2

[eluser]The Revel[/eluser]
Scratch that, would help is I entered a number that would give a result from the DB.
#3

[eluser]InsiteFX[/eluser]
I would not use $_POST for your input! Use CI input->post




Theme © iAndrew 2016 - Forum software by © MyBB