Welcome Guest, Not a member yet? Register   Sign In
Cannot test if a field is empty or not
#3

[eluser]caperquy[/eluser]
Thanks for answering that fast. In fact I simplified the code when I put my first question on line. The exact code is a little bit more complex since I retrieve other fields as well. The code in the model is as follows ($critere represents the word I am looking for in the database) :

Code:
[b]function recherche($critere)[/b]
this->db->select('COTE, TITRE, EDITEURS, RESUME, DESCRIPTEURS, MOTSCLES, DIVERS');
$this->db->from ('catalogue_dvd');
this->db->like ('TITRE',$critere);
$this->db->or_like ('EDITEURS',$critere);
$this->db->or_like ('RESUME',$critere);
$this->db->or_like ('DESCRIPTEURS',$critere);
this->db->or_like ('MOTSCLES',$critere);
$this->db->or_like ('DIVERS',$critere);
[b]return $this->db->get();
[/b]


The code in the controller is as follows :

Code:
$data['resultats'] = $this->catalogue_model->recherche($critere)->result();
$i=count($data['resultats']);
$j=0;
while ($j<$i)
    {
    if (is_null($data['resultats'][$j]->DIVERS))
        {
            echo "Divers empty<br />";
    }else{
            echo "Divers not empty<br />";
    }
    j++;
}

Obviously when I will get the solution to my problem the echo instructions will be replaced by more sophisticated ones.
I hope this will be useful tp you


Messages In This Thread
Cannot test if a field is empty or not - by El Forum - 01-24-2011, 04:59 AM
Cannot test if a field is empty or not - by El Forum - 01-24-2011, 05:49 AM
Cannot test if a field is empty or not - by El Forum - 01-24-2011, 07:55 AM
Cannot test if a field is empty or not - by El Forum - 01-24-2011, 09:03 AM
Cannot test if a field is empty or not - by El Forum - 01-24-2011, 09:06 AM
Cannot test if a field is empty or not - by El Forum - 01-24-2011, 02:47 PM
Cannot test if a field is empty or not - by El Forum - 01-25-2011, 04:09 AM
Cannot test if a field is empty or not - by El Forum - 01-25-2011, 04:14 AM
Cannot test if a field is empty or not - by El Forum - 01-25-2011, 04:17 AM
Cannot test if a field is empty or not - by El Forum - 01-25-2011, 04:21 AM
Cannot test if a field is empty or not - by El Forum - 01-25-2011, 04:37 AM
Cannot test if a field is empty or not - by El Forum - 01-25-2011, 04:52 AM
Cannot test if a field is empty or not - by El Forum - 01-25-2011, 05:00 AM
Cannot test if a field is empty or not - by El Forum - 01-25-2011, 09:27 AM



Theme © iAndrew 2016 - Forum software by © MyBB