Model
$q = $this->db->get_where('person', array('p_id' => $p));
if($q->num_rows()!=1)
{
redirect('General_Area/Home');
exit();
}
else
{
. . .
Ok So once the model is initialized it queries the db and looks for exactly one match and if found it moves on the else statement. However if not found it will redirect('General_Area/Home');
How do I pass a message in there? In my controller I am returning an object if the query is successful.
And in my view i am echo obj->table_col_name
$q = $this->db->get_where('person', array('p_id' => $p));
if($q->num_rows()!=1)
{
return $Error = 'You have not been found!...';
#redirect('General_Area/Home');
exit();
}
else
{
. . .
If the $q was not successful I want to be able to echo $error; in the view for the user to see the message.
In your Model
In the Controller
In your View
Message on redirect
Also if you want to send a message when you redirect to another page you can use in your controller
So you can print the message in the view like
Read more about Flashdata.