[eluser]jacobson[/eluser]
Hello I have a problem... In my view i have the foreach loop which generates the links one under the another. Now each of this links has a button "enroll" and I have the jquery script which adds the data to database after clicking this "enroll" button. Now I want to have an If statement which will check whether the user is enrolled to the event or not. If hes not than the enroll button will be visible if he's enrolled, it'll be invisible. In order to do this I need to check the mysql database if there exist the record.
In the foreach loop there is "id" generated which is used to enroll user to event and also would be needed to make the button invisible. I know that accessing model from the view is "bad" but mabe someone has any good idea how to do this in some other way ?
Mabe I'll provide a little bit of my code ...
Code:
foreach ($records as $item) {
?>
<div class="content_main_entry"><a >id; ?>">
<span class="content_main_entry_value">Time</span></a></div>
<div class="content_main_entry_enroll">
<?php
$is_logged_in = $this->session->userdata('is_logged_in');
if (isset($is_logged_in) && $is_logged_in == TRUE){ ?>
<!-- and here I want the if statement which will check if the button should be visible or not -->
<a href="##">id; ?>')">Enroll</a>
<?php
} else if(!isset($is_logged_in) || $is_logged_in != TRUE){
?> <a href="##">Enroll</a> <?php
}
?>
</div>
<?php
}
?>
Thx for responding