I'll assume you're trying to block out a login box if the user is logged in. Here's what you'll need to do:
In the view:
<?php if ($show_login): ?>
<!-- login box code here -->
<?php endif; ?>
In the controller's action that calls the view:
if (is_logged_in() && $this->my_model->check_something()) {
$data['show_login'] = false;
}
else {
$data['show_login'] = true;
}
$this->load->view('myview', $data);
In the model:
function check_something() {
// execute the SQL statements
// and return true/false depending on what you get
}
Refer to CodeIgniter's Active Record documentation to figure out how to setup your SQL statements.
If this isn't what you were looking for, try making your question more detailed, maybe with whatever code you have.