使用CodeIgniter的变量查询

Hello community I have an issue working on my project and I'm searching for help and a way to solve it. I hope someone of you could help me to achieve that. Thanks for your help.

Background: I'm working on PHP framework Codeigniter v3. I show information from MySQL DB on Data Tables.

ISSUE I want to show a JOIN QUERY info on one Data Table but the information that shows has to be diferent depending on which option the user select.

CONTROLLER 1 (This controller displays all "formulas" in the sistem on one Data Table. What I want to do is when user CLICKS on the first button (onclick="mostrar('."'".$ALIAS_MODEL->id_formula."'".')") that the view changes to another view where there will display a new Data Table with THE CONTENT of the "formula" clicked...) I want to say that I don't have any problem with the first Data Table.

function to fill the formulas's table

    foreach ($list as $ALIAS_MODEL) 
    {
        $row = array();
        $row[] = $ALIAS_MODEL->id_formula;
        $row[] = $ALIAS_MODEL->nombre_formula;

        $row[] = '<a class="btn btn-round btn-info btn-icon btn-sm edit" href="contenidoFormula"  onclick="mostrar('."'".$ALIAS_MODEL->id_formula."'".')"><i class="fas fa-search-plus"></i></a>
        <a class="btn btn-round btn-warning btn-icon btn-sm edit" href="javascript:void(0)"  onclick="edit_formula('."'".$ALIAS_MODEL->id_formula."'".')"><i class="far fa-edit"></i></a>
        <a class="btn btn-round btn-danger btn-icon btn-sm remove" href="javascript:void(0)"  onclick="delete_formula('."'".$FORMULA->id_formula."'".')"><i class="fas fa-times"></i></a>';

        $data[] = $row;
    }
    some code for printing data...
}

CONTROLLER 2

function to fill the content formulas's table
    foreach ($list as $ALIAS_MODEL_TWO) 
    {
        $no++;
        $row = array();
        //$row[] = $no;
        $row[] = $ALIAS_MODEL_TWO->nombre_formula;
        $row[] = $ALIAS_MODEL_TWO->descripcion_material;
        $row[] = $ALIAS_MODEL_TWO->unidad_material;
        $row[] = $ALIAS_MODEL_TWO->costo_material;

        $row[] = '
        <a class="btn btn-round btn-danger btn-icon btn-sm remove" href="javascript:void(0)"  onclick="llenarContenido()"><i class="fas fa-times"></i></a>';

        $data[] = $row;
    }
    some code for printing data...
}

MODEL This model's functions is call to fill the Data Table

private function _get_content($id_formula)
{
    $this->db->select('nombre_formula,descripcion_material,unidad_material,costo_material,porcentaje_formula,tiempo_proceso,porcentaje_agua_bomba,gramos_por_aplicacion,observaciones_detalle_formula');
    $this->db->from('formulas');
    $this->db->join('detalle_formula', 'formulas.id_formula = detalle_formula.id_formula');
    $this->db->join('materiales', 'detalle_formula.id_material = materiales.id_material');
    $this->db->where(array('formulas.id_formula' => $id_formula));

    some extra code here to print data...
}

I want that the variable $id_formula changes its value depending on wich option users clicks

JS Script

function mostrar(id_formula) 
{
  //alert(id_formula);
  return id_formula;
}

$(document).ready(function() 
{
    table = $('#tableName').DataTable({ 
"processing": true, 
"serverSide": true,

 //Carga la informacion desde el archivo AJAX
 "ajax": {
 "url": base_url + "CONTROLLER/FUNCTION/"+id_formula,
 "type": "POST"
  },
});
});

VIEW

...html code
<table id="tableName" class="table table-striped table-bordered" cellspacing="0" width="100%">
    <thead>
      <tr>
        columns...
      </tr>
    </thead>
    <tfoot>
      <tr>
        columns...
      </tr>
    </tfoot>
    <tbody>

    </tbody>
  </table>
html code...