Welcome Guest, Not a member yet? Register   Sign In
Assigning Query (Read) Results to Variables
#1

[eluser]nydeveloper[/eluser]
I apologize in advance if this is a simple question, but I've been unable to figure it out or find any reference to it anywhere.

I'm retrieving specific results from a DB table, and then displaying them. Next, what I'd like to do is assign each individual result to a variable. I'd then like to use these variables in other functions. In the code below, I'd like to assign math_grade, history_grade, art_grade, and science_grade to variables that I can use in formulas and DB insert/updates.

Code:
function get_student_grades($student_id)
    {
  $this->db->where('student_id', $student_id);
  $this->db->select('math_grade, history_grade, art_grade, science_grade');

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

Any help here is greatly appreciated!


Messages In This Thread
Assigning Query (Read) Results to Variables - by El Forum - 01-24-2012, 08:50 PM
Assigning Query (Read) Results to Variables - by El Forum - 01-24-2012, 09:02 PM
Assigning Query (Read) Results to Variables - by El Forum - 01-24-2012, 09:23 PM
Assigning Query (Read) Results to Variables - by El Forum - 01-24-2012, 09:25 PM
Assigning Query (Read) Results to Variables - by El Forum - 01-24-2012, 09:31 PM
Assigning Query (Read) Results to Variables - by El Forum - 01-26-2012, 12:55 AM
Assigning Query (Read) Results to Variables - by El Forum - 01-26-2012, 01:26 AM
Assigning Query (Read) Results to Variables - by El Forum - 01-26-2012, 05:26 PM
Assigning Query (Read) Results to Variables - by El Forum - 01-26-2012, 05:35 PM
Assigning Query (Read) Results to Variables - by El Forum - 01-26-2012, 06:42 PM
Assigning Query (Read) Results to Variables - by El Forum - 01-26-2012, 08:17 PM
Assigning Query (Read) Results to Variables - by El Forum - 01-26-2012, 10:48 PM
Assigning Query (Read) Results to Variables - by El Forum - 01-29-2012, 11:04 PM
Assigning Query (Read) Results to Variables - by El Forum - 01-29-2012, 11:18 PM
Assigning Query (Read) Results to Variables - by El Forum - 01-30-2012, 02:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB