I need to check that two variables match fields in a row where the id = x.
Firstly I checked that the row with ID x exists I then need to check that both $category and $title are equal to the values in that row.
How can I compare the variables to the fields and return true if they match???
function match_id($category,$id,$title)
{
$this->db->where(array('id' => $id));
$query = $this->db->get('news');
if ($query->num_rows() > 0){
foreach ($query->result() as $row) {
$data = array(
'category' => $row->category,
'title' => $row->title
);
}
//If category == $category && title == $title, return true
return true;
}
else{
return false;
}
}
1 Answer