I want to check if a string exists in a row in a specific table, i have had no luck in doing this but i was able to gain an understanding on how $query->num_rows(); works and i thought i would have to do something like.
The code i tried below i thought will check if the d009 value exists in the dept_no row and if their are no rows with the value d009 then it should produce an error message.
When i run the code it does not echo any message
$this->db->where('dept_no', 'd009');
$query = $this->db->get('dept_manager');
if($query->num_rows()==0)
{
echo "true";
}
else
{
echo "false";
}
dept_manager table
d009 a
d008 b
d007 c
I think
if.. elseshould be opposite of what you have specifiedI mean if num_rows() returns zero rows means value not present in the row….