I don't know if I formulated this question correctly but let me try to explain myself better.
I have following menu on my page that outputs new result once new selection is choosen:
Izaberite pol:
and Izaberite studente:
contains 3 options each oba, zenski, muski
and oba, stari, novi
respectively.
I've added some Javascript to recognise option changing and automatically call controller action:
$("select.filter").change(function () {
var str = "";
$("select option:selected").each(function () {
str += $(this).attr('value') + "/";
});
window.open("http://vipassana-srbija.comli.com/index.php/login/trust/"+str,"_self");
});
As you can see from Javacript code it will call controller's Login trust function:
public function trust($tabela="letnji",$pol="oba", $student="oba"){
$data['rezultat']= $this->prijava_model->zgrabi_tabelu($tabela,$pol,$student);
$data['tabela']=$tabela;
$data['pol']=$pol;
$data['student']=$student;
$prijavljen = $this->session->userdata('prijavljen');
if($prijavljen)
{
$this->load->view('prijava/trust.php', $data);
}
else
{
redirect('login');
}
}
Further you will notice that it uses Prijava_model
model's zgrabi_tabelu
function:
function zgrabi_tabelu($tabela,$pol,$student){
$upit_rezultat=array();
if($pol=="oba" && $student="oba")
$upit = $this->db->get($tabela);
else if($pol!="oba" && $student!="oba")
$upit=$this->db->get_where($tabela,array('pol'=>$pol,'stari_novi_student'=>$student));
else if($pol!="oba" && $student=="oba")
$upit=$this->db->get_where($tabela, array('pol'=>$pol));
else if( $pol=="oba" && $student!="oba")
;//$upit=$this->db->get_where($tabela, array('stari_novi_student'=>$student));
foreach($upit->result() as $red){
array_push($upit_rezultat, $red);
}
return $upit_rezultat;
}
And I think that here in the model's zgrabi_tabelu
function lies problem as every possible combination works fine, except for the last one, when I try to grab data by changing only last selection menu Izaberite studente:
leaving all other options intact:
&& WILL NOT WORK
but when I change previous field Izaberite pol:
to anything beside Oba
it will work fine:
And lastly let me provide you with HTML of menu items:
<div>
<label>Izaberite kurs:</label>
<select class="kurs" id="kurs_datum">
<option value="letnji" selected='selected'>Letnji kurs(27.6 - 7.7.2012)</option>
<option value="jesenji" >Jesenji kurs(10.10 - 21.10.2012)</option>
</select>
</div>
<div>
<label>Izaberite pol:</label>
<select class="filter" id="pol">
<option value="oba" selected='selected'>Oba</option>
<option value="zenski" >Ženski</option>
<option value="muski" >Muški</option>
</select>
</div>
<div>
<label>Izaberite studente:</label>
<select class="filter" id="student">
<option value="oba" selected='selected'>Oba</option>
<option value="novi" >Novi</option>
<option value="stari" >Stari</option>
</select>
</div>
Hope this makes sense. I will gladly clarify this further if necessary.
Any help appreciated.
zgrabi_tabelu
function but I cannot see what.. Thank - daniel.tosaba 2012-04-03 21:33
function zgrabi_tabelu($tabela,$pol,$student){
$upit_rezultat=array();
if($pol=="oba" && $student="oba")
$upit = $this->db->get($tabela);
else if($pol!="oba" && $student!="oba")
$upit=$this->db->get_where($tabela,array('pol'=>$pol,'stari_novi_student'=>$student));
else if($pol!="oba" && $student=="oba")
$upit=$this->db->get_where($tabela, array('pol'=>$pol));
else if( $pol=="oba" && $student!="oba")
;//$upit=$this->db->get_where($tabela, array('stari_novi_student'=>$student));
foreach($upit->result() as $red){
array_push($upit_rezultat, $red);
}
return $upit_rezultat;
}
You left out a = on the first line...
if($pol=="oba" && $student="oba")
should be
if($pol=="oba" && $student=="oba")
I believe the IF function will return false because its a false operator.
Stay cool - David Lawrence 2012-04-03 21:44
In your jquery call to open a new window, i think you want to remove that comma and put a slash there
so change this:
window.open("http://vipassana-srbija.comli.com/index.php/login/trust/"+str,"_self");
to:
window.open("http://vipassana-srbija.comli.com/index.php/login/trust/"+str+"/_self");
An additional note, where you're calling your view '$this->load->view('prijava/trust.php', $data);' - should trust.php not be just trust - CI adds .php to the end when 'requiring' in views.