Hi there,

I am developing a site for a recruitment agency, and I have now come to the point where I need to develop a ranking system of some kind to pull the best candidates for a particular job out of the database and display it or notify the candidates of the job. the candidates fill out an application form which I am going to use to rank then..

now, I don’t know where to start or how exactly it will work.. any suggestions will be appreciated.

PS. I’m still young developer so I dont hve much experience...

4 Years
Discussion Span
Last Post by renierdbruyn

Thanks for your reply.
they would be ranked on their quilifation, experience in a certian job field, prefered salary, skills, if they are willing to relocate, on their location and age.


I'm not too sure how you're thinking of doing it but if this was me I would collect years of experience in the job they are applying to, their age (could break certain discrimination laws), their location by postcode and similar variables when they apply. I would then enter desirable figures when I'm filtering (I.E. I'm looking for a mature individual (say, 30), with 6 years experience in the industry and no more than 30 miles from my office.). I would then execute a PHP script that would find the best matching individual and list the next best belo and so forth. I couldn't see it being done any other way without some sort of NASA standard algorithm. Don't take my word for it though as I'm quite new to this too.

I built the ranking algorithm at http://vote4mc.com and it's a similar thing but for gaming servers rather than people.


okay so what ive got so far:

//I get the candidates data from the database like so:

class ranking_model extends CI_Model {

    function __construct() {

    function age() {
        $sql = "SELECT * FROM membership";
        $query = $this->db->query($sql)->result();
        foreach ($query as $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 the date to get month, day and year
            $date = explode("/", $date);
            //get age from 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;

    function job_experience() {
        $sql = "SELECT * FROM  job_list 
        JOIN job_history
        ON job_list.job_history_id = job_history.job_history_id";
        $query = $this->db->query($sql)->result();

        foreach ($query as $row) {
            $start = $row->start_date;
            $end = $row->end_date;

//            //explode the date to get month, day and year
            $start = explode("-", $start);
            $end = explode("-", $end);
//            //get age from date or birthdate
            $exp_in_years = (date("md", date("U", mktime(0, 0, 0, $start[2], $start[1], $start[0]))) > date("md", mktime(0, 0, 0, $end[2], $end[1], 0)) ? ((date("Y", mktime(0, 0, 0, 0, 0, $end[0])) - $start[0])) : (date("Y", mktime(0, 0, 0, 0, 0, $end[0])) - $start[0]));

        return $exp_in_years;


    function location() {
        $sql = "SELECT * FROM personal";
        $query = $this->db->query($sql)->result();

        foreach ($query as $row) {
            $city = $row->city;
        return $city;

    function relocate() {
        $sql = "SELECT * FROM personal";
        $query = $this->db->query($sql)->result();

        foreach ($query as $row) {
            $relocate = $row->relocate; //are you willing to relocate yes/no
        return $relocate;

    function get_personal() {
        $this->db->join('personal', 'membership.id_number = personal.id_number');
        $query = $this->db->get()->result();

        foreach ($query as $row) {
        return $query;
//and the advert details like this:

    function get_advert() {
        $sql = "SELECT * FROM job_advert";
        $query = $this->db->query($sql)->result();
        foreach ($query as $row) {

            $job_id = $row->job_id;
            $job_title = $row->job_title;
            $salary_offered = $row->salary_offered;
            $is_negotiable = $row->negotiable;
            $company_location = $row->company_location;
            $experience = $row->required_experience;
            $age = $row->age;


now I don't know how to compare the candidates data with the data that I get from the job_adverts table. I really have no idea. Help of any sort would be appreciated.

Database structure

bold PK itacic is FK.

membership(id_number, firstname, lastname, username, email, phone, password, role, Reg_time, activated);

personal(person_id, address, city, licence, id_number, gender, relocate, minimum_salary, prefered_salary, contract_type);

job_list(job_list_id, job_history_id, start_date, end_date, income, company_name, industry_type, reason_for_leaving, job_title);

job_history(job_history_id, id_number);

job_advert(advert_id, job_title, job_description, start_date, end_date, salary_offered, negotiable, benefits, company_location, required_experience, age);

I have more tables in the db, but these are the ones I use for ranking.

Edited by renierdbruyn

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.