How can i set dropdowns to show only part of data from a table using relations ?
dropdown
- Single Page
Posted 01 September 2013 - 10:06 AM
Posted 01 September 2013 - 12:43 PM
take a look at this.
Posted 02 September 2013 - 10:47 AM
Thanks for the replay, I have one more question :
My model :
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Dropdown extends CI_Model { function __construct() { parent::__construct(); // add if needed } public function get_agent($table, $nume) { $this->db->select('id, nume'); $this->db->where('nume', $nume); $this->db->order_by('id desc'); return $this->db->get($table); } } /* End of file dropdown.php */ /* Location: ./application/models/dropdown.php */
My controller :
// added for test $this->load->model('dropdown'); $nume = $this->dropdown->get_agent("agenti","XXXX"); foreach ($nume->result() as $row) { $agent_array[$row->id] = $row->nume; } $crud->field_type('agent_dec','dropdown',$agent_array); //output $output = $crud->render();
how can i add more to the XXXX ? like "XXXX, YYYY, ZZZZZ"
Thanks
Posted 02 September 2013 - 12:17 PM
just add this code in model :
public function get_agent($table, $xxxx, $yyyy, $zzzz){ $this->db->select('id, nume'); $this->db->where('nume', $nume); $this->db->or_where('xxxx',$xxxx); $this->db->or_where('yyyy',$yyyy); $this->db->or_where('zzzz',$zzzz); $this->db->order_by('id desc'); return $this->db->get($table); }
then, you can do it in controller :
$nume = $this->dropdown->get_agent("agenti","XXXX","YYYY","ZZZZ");
Posted 02 September 2013 - 13:01 PM
That seams to wok with a small modification :
public function get_agent($table, $xxxx, $yyyy, $zzzz){
$this->db->select('id, nume');
$this->db->where('nume', $nume);
$this->db->or_where('nume,$xxxx);
$this->db->or_where('nume',$yyyy);
$this->db->or_where('nume',$zzzz);
$this->db->order_by('id desc');
return $this->db->get($table);
because the column is nume .. but is there a better way to do this ? it dosent seam that good.
}