Bootstrap carousel & Codeigniter |
Hi Everyone,
Sorry if this is a basic question but for some unknown reason I am stuck, I would like to show a carousel of info on a site using codeigniter and MySQL with an active class on the first row and then a non active on the others, Below is my Model and View: PHP Code: function get_where($id) { PHP Code: <section class="block news" id="news"> It is probably really simple but i just can't get my head around it, if someone could help that would be much appreciated. Thanks
Hard to know for sure without seeing your controller where you are using the model and passing the data to the view. What exactly isn't working?
My best guess would be two things:
- use $i === 1 instead of $i == 1. - in your foreach(), choose a different name for the variable after 'as', then change all of the references to $news inside the loop. At best, foreach($news->result() as $news) is confusing; at worst, it may be causing errors. If you're not using the value of $i for any other purpose, though, I would suggest setting $item_class = 'item active' before the loop and setting it to 'item' just before closing the loop, removing the variable $i and the conditional completely. You should also check your HTML against the Bootstrap documentation, and make sure that within the foreach() loop you close every tag you open. Here's an untested attempt at fixing everything obvious: PHP Code: <section class="block news" id="news">
Hi,
Thanks very much, it is working now. Half the issue was two of the div's were being closed after the foreach. But all good. Thanks |
Welcome Guest, Not a member yet? Register Sign In |