update
all of methods work. @niloysaha, @aerox, @ray, @susheelmishra.
but if want compare more fields such work experience, salary, etc? @ray add more params
function check_job_adverts($age, $experience, $salary){ } ?
or how approach this? relevantly new this, please excuse me if ask noobish questions..
i have following:
function age() { $sql = "select * membership"; $query = $this->db->query($sql)->result(); foreach ($query $row) { $id = $row->id_number; $dobs = substr($id, 0, 6); $dob = str_split($dobs, 2); $day = date('d', mktime(0, 0, 0, 0, $dob[2], 0)); $month = date('m', mktime(0, 0, 0, $dob[1] + 1, 0, 0)); $year = date('o', mktime(0, 0, 0, 0, 0, $dob[0] + 1)); $date = "$day/$month/$year"; //explode date month, day , year $date = explode("/", $date); //get age date or birthdate $age = (date("md", date("u", mktime(0, 0, 0, $date[0], $date[1], $date[2]))) > date("md") ? ((date("y") - $date[2]) - 1) : (date("y") - $date[2])); return $age; } i want know how use $age variable in query. example: want compare $age job_advert table can have age requirement, , display in membership table meets required age job_advert.
try :
function age() { $data = array(); $sql = "select * membership"; $query = $this->db->query($sql)->result(); foreach ($query $key=>$row) { $id = $row->id_number; $dobs = substr($id, 0, 6); $dob = str_split($dobs, 2); $day = date('d', mktime(0, 0, 0, 0, $dob[2], 0)); $month = date('m', mktime(0, 0, 0, $dob[1] + 1, 0, 0)); $year = date('o', mktime(0, 0, 0, 0, 0, $dob[0] + 1)); $date = "$day/$month/$year"; //explode date month, day , year $date = explode("/", $date); //get age date or birthdate $age = (date("md", date("u", mktime(0, 0, 0, $date[0], $date[1], $date[2]))) > date("md") ? ((date("y") - $date[2]) - 1) : (date("y") - $date[2])); #return $age; #not returning age instead inserting in array $data[$key]['id'] = $id; $data[$key]['age'] = $age; } $data = $this->another_funcion_call($data); #calling function recieve array of ids / age return $data; } function another_funcion_call($arrayofidsage){ //loop through array , foreach($arrayofidsage $key=>$each){ echo "id :".$each['id'].' age : '.$each['age'].'<br>'; } }
Comments
Post a Comment