0

i cant load my css and js in the view file i already added them in the folder and already set my base url these code however is working with a project i did on a lower version of codeigniter . what seems to be wrong? my view:

 <link href="<?php echo base_url()?>js/dataTables/dataTables.bootstrap.css" rel="stylesheet" />



    </br></br>
            <div class="panel panel-primary" style=" width: 1050px; border-radius: 0">
                    <div class="panel-heading" style="border-radius: 0 ">user List    <button  data-toggle="tooltip"   data-placement="bottom" title="Print Customer Order" style="border-radius: 0px;"type="button" class="btn btn-default" aria-label="Left Align">
                                        <a href="<?php echo base_url() . 'admin/printlist/'; ?>">
                                                   Print List
                                                      </a>
                                            </button> </div>
                    <div class="panel-body" style="border-radius: 0 ">  

                        <table id="myTable" class="table table-bordered" >  
                            <thead>  

                                <tr>  

                                     <th>Surname</th> 
                                    <th>Name </th>  
                                    <th>Age</th>  
                                    <th>School</th>  
                                   <th>Course</th>  
                                    <th>Email</th>  

                                </tr>  
                            </thead>  
                            <tbody>  


                               <?php foreach ($user as $users): ?>
                                    <tr>
                                        <td><?php echo $users->surname; ?></td>
                                        <td><?php echo $users->name; ?></td>
                                        <td><?php echo $users->age; ?></td>
                                        <td><?php echo $users->school; ?></td>
                                        <td><?php echo $users->course; ?></td>
                                        <td><?php echo $users->email; ?></td>

                                        </td>
                                    </tr>
                                <?php endforeach; ?>
                            </tbody>  
                        </table>  
                               </div>

                    </div>



                </div>
        </div>
    </div>

            <script src="<?php echo base_url() ?>js/dataTables/jquery.dataTables.js"></script>
            <script src="<?php echo base_url() ?>js/dataTables/dataTables.bootstrap.js"></script>
            <script>
                $(document).ready(function() {
                    $('#myTable').dataTable({
                        "aaSorting": [[0, "asc"]]
                    });
                });
            </script>
5
  • 1
    Are you loading the CSS and JS in the <head> of your page? Commented Jan 29, 2016 at 8:18
  • <?php echo base_url()?> change base_url to site_url if you found index.php in your url. Commented Jan 29, 2016 at 8:19
  • At the end of <?php echo base_url()?> is maybe a / missing? You can see this in de developer console when you hit the F12 key in your browser. Commented Jan 29, 2016 at 8:22
  • checked all your comments and they are all fine Commented Jan 29, 2016 at 8:39
  • @Christian, do you get specific errors? Commented Jan 29, 2016 at 8:56

3 Answers 3

2

I have done some research and i found that the default location for css files is the same level as the application in Codigniter. I.E:

/css
/application

Check this first if that's your case. You can fix this with some simple ../ in front of the echo.

Another thing I noticed is, your CSS file is located in a js folder (js/dataTables/)? Maybe this is a fast copy/paste fault?

Sign up to request clarification or add additional context in comments.

Comments

2

Put CSS and JS folder in your project folder root(Application level).

I have created 'assets' folder in my project and put css and js folder in it. It's working fine.

assets/js/jquery.bootstrap-touchspin.js">

Comments

0

I think there is a mistake Replace <?php echo base_url()?> to <?php echo base_url(); ?>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.