Hi All,
I want to convert mysql results into associative array like below
Code:
function jobs() // previously i was using this function and i was declaring as mentioned in $job_arr
{
$job_arr = array(
' ' => "Please select job type",
'1'=>"Full Time",
'2'=>"Part Time",
' 3' =>"Freelancing"
);
return $job_arr;
}
But i want to get these results from my mysql result
Code:
function jobs()
{
$sql = "Select * from jh_job_type where Status = 1";
$query = $ci->db->query($sql);
$result = $query->result_array();
// Id,Name are the field names
$job_arr = ''; // i started doing with foreach but did not get required result.
return $job_arr;
}
Anyone know how to do this one?
Bookmarks