Welcome Guest, Not a member yet? Register   Sign In
undefined variable (newbie)
#18

[eluser]xwero[/eluser]
You don't need the loop as result_array will return the rows as you want them.

The reason why result isn't known is because the jobs table is empty.

A rule of thumb: if there is a possibility the variable will not be set along the way set it with the correct type as high up as possible.
Code:
$result = array();
$query = $this->db->get('jobs');

    foreach ($query->result_array() as $row)
    {
      $result[] = $row;
    }

    return $result;
But don't use this snippet use
Code:
function get_jobs() {
    $query = $this->db->get('jobs');
    return $query->result_array();
}


Messages In This Thread
undefined variable (newbie) - by El Forum - 02-12-2008, 05:50 PM
undefined variable (newbie) - by El Forum - 02-12-2008, 07:59 PM
undefined variable (newbie) - by El Forum - 02-12-2008, 08:11 PM
undefined variable (newbie) - by El Forum - 02-12-2008, 08:35 PM
undefined variable (newbie) - by El Forum - 02-12-2008, 09:06 PM
undefined variable (newbie) - by El Forum - 02-12-2008, 09:23 PM
undefined variable (newbie) - by El Forum - 02-12-2008, 09:27 PM
undefined variable (newbie) - by El Forum - 02-12-2008, 09:31 PM
undefined variable (newbie) - by El Forum - 02-12-2008, 09:31 PM
undefined variable (newbie) - by El Forum - 02-12-2008, 09:37 PM
undefined variable (newbie) - by El Forum - 02-12-2008, 10:20 PM
undefined variable (newbie) - by El Forum - 02-13-2008, 03:42 AM
undefined variable (newbie) - by El Forum - 02-13-2008, 03:46 AM
undefined variable (newbie) - by El Forum - 02-13-2008, 05:41 AM
undefined variable (newbie) - by El Forum - 02-13-2008, 01:01 PM
undefined variable (newbie) - by El Forum - 02-13-2008, 01:10 PM
undefined variable (newbie) - by El Forum - 03-24-2009, 01:46 AM
undefined variable (newbie) - by El Forum - 03-24-2009, 02:09 AM
undefined variable (newbie) - by El Forum - 03-24-2009, 02:20 AM
undefined variable (newbie) - by El Forum - 03-24-2009, 02:32 AM
undefined variable (newbie) - by El Forum - 03-24-2009, 02:42 AM
undefined variable (newbie) - by El Forum - 07-06-2011, 06:20 AM



Theme © iAndrew 2016 - Forum software by © MyBB