Tutorial Details
- Topic: CodeIgniter
- Difficulty: Intermediate
- Tutorial Format: Video
In today’s video tutorial, we are going to use CodeIgniter to pull information from a database and display it in a sortable table structure. This is a quite common task, especially inside admin areas, for displaying database records. We’ll be utilizing a few different utilities, such as the active records library and pagination.
Catch Up
- Day 1: Getting Started With the Framework
- Day 2: Database Selecting Methods
- Day 3: Sending Emails
- Day 4: Newsletter Signup
- Day 5: CRUD
- Day 6: Login
- Day 7: Pagination
- Day 8: AJAX
- Day 9: File Uploading and Image Manipulation
- Day 10: The Calendar Library
- Day 11: File and Directory Operations
- Day 12: Shopping Cart
- Day 13: Extending the Framework
- Day 14: Security
- Day 15: Profiling, Benchmarking & Hooks
- Day 16: Displaying & Sorting Tabular Data
Day 16: Displaying & Sorting Tabular Data
Thanks for watching! Any questions/thoughts?


RoyalSlider – Touch-Enable ... only $12.00 
Just for your note. Using file name like Film_model.php does not work in Ubuntu/Linux. It is better to use all lower case like film_model.php. I think it is better to use lowercase for all the file names.
i think most of us use all smaller case for filenames. I’ve finished my codeigniter tutorial and this site really contributed to all of my knowledge. I have a site now based on this 13 days of codeigniter, just click on my link.
I know it still has a long way to go, but as a newbie starting from scratch i think i did a pretty decent job.
Was this the end of CI from scratch?
I wish you guys would edit the earlier articles in the series with the full list of tuts, so when I’m at day 6, I can click on day 7 right from it. Or day 13 if I feel like it. At least that way I can see how far it goes.
thanks!
How i can convert a DATE before print in the table
please help me
Excellent! Just what I needed! Cheers!!
Looking forward to more in these series.
Exellent episode keep on working in this kind of tutorials that help us a lot.
thank you very much.
Hi,
With Firefox 4.0 the down arrow icon at sorting has strange characters before. I have five small squares, 0081 number inside them. Somebody saw that? Who knows why?
There is no green DIV with information about the next tutorial :)
I love this tutorials!!! It`s great and very helpful!
thank you so much.. you really help me to learn codeigniter.. thanks a lot
Hello Burak, thanks for your tutorial …
I’ve see that if you are in any page, if you click on a title to change sorting of column, it all comes back to page 1 … The segment (5) page does not take … then I tried to do this:
<?php foreach($fields as $field_name => $field_display): ?>
<th <?php if ($sort_by == $field_name) echo “class=\”sort_$sort_order\”" ?>>
<?php echo anchor(“films/display/$field_name/” . (($sort_order == ‘asc’ && $sort_by == $field_name) ? ‘desc’ : ‘asc’).”/”.$this->uri->segment(5), $field_display); ?>
</th>
In this way, is functioning, but the question is: is this the correct way?
Thanks
Hi!! Thanks for yours tutorials! I watched almost in a week! I’m learning a lot! I’m from Argentina but your english is very well so I can understand! :)
I have a doubt… Why don’t you use “table” library? like in day 6: Pagination? These advance functions don’t work on that library so you have to make the table manually??
Thanks again!
JP Cook
videos not watch. Help me
Hey Burak!
I’m using Aptana Studio (ver. 3) too, and how did you do that, when you typed “html:5″, it converted a blank HTML5 template?
Oh! I found it, Zen Coding! : )
Lado,
If you come back here and read this, I don’t see a version of zen coding for aptana. Is it at google here where you found it? http://code.google.com/p/zen-coding/downloads/list
I see one for about every ide and editor except for aptana.
I know there is a way to add snippets to a bundle.rb file but when I looked in the aptana files I found about a thousand bundle.rb files and the instructions I had at the time assumed I was a mind reader and new which one they were talking about. :-)
I’m currently using notepadd++ and/or gedit depending on the OS and they both have a snippet plugin that comes with them and just has to be added in the plugin manager.
Thanks
Great tutorial… thanks
Great tutorials Burak! Thank you!
I’ve been using notepad++ for all of these tuts when on my win7 and gedit on Ubuntu laptop. Something I haven’t seen since I used it once a few years ago was character map and it was in MS Word. I figured out I can use all the online utf-8 characters if I switch notepad++/gedit to use utf-8 encoding and it works since it is a web standard. So I learned something new.
I’m not sure about the comments on uppercase names because I haven’t had a problem on win with IIS or on Ubuntu with Apache. Both are running php5.
I notice in CI (at least in the recent version) all the library files and class names are capitalized like you have been doing.
Also this is more in line with naming conventions like Zend (Zend_Controller_PluginAbstract) except that they change the prefix to “Zend” instead of “ZEND”
I think it’s a good idea to put restrictive naming conventions like all class names start with a prefix or all class names start with a capital letter. This ensures that if someone has to make a change in the core it won’t break everything. It makes things more specific and certain. IMHO
Thanks for these great tutorials, Burak!
I have a quick question, shouldn’t we use htmlspecialchars() in order to escape the output from the database?
Hi Barak!
Thank for your fabulous tutorials…
I have a problem with the pagination links but I can’t figure out why. Here is the code:
Hello!
i’m too new to CI to prentend having ancounter a bug. There’s must be a mistake in my code! I’ve read documentation and browsed forums but i can’t find where!
Any help is welcome:
I want to a simple pagination with sorting features. Here is the code:
load->model(‘project_model’);
$results = $this->project_model->search($limits,$offset,$sort_by, $sort_order);
$data['projects'] = $results['rows'];
$data['num_results'] = $results['num_rows'];
//pagination
$this->load->library(‘pagination’);
$config = array();
$config['base_url']=site_url(“projects/display/$sort_by/$sort_order/$offset”);
$config['total_rows'] = $data['num_results'];
$config['per_page'] = $limits;
$config['uri_segment'] = 5;
$this->pagination->initialize($config);
$data['pagination']= $this->pagination->create_links();
$this->load->view(‘projects’,$data);
}
}
?>
The search function works great, i can type url such like:
http://10.153.9.6/dev/index.php/projects/display/id/desc
http://10.153.9.6/dev/index.php/projects/display/id/desc/10
http://10.153.9.6/dev/index.php/projects/display/counrty/asc/400
http://10.153.9.6/dev/index.php/projects/display/name/asc/11
But the pagination links are wrong, I obtain:
http://10.153.9.6/dev/index.php/projects/display/id/desc/0/240
instead of:
http://10.153.9.6/dev/index.php/projects/display/id/desc/240
I thought the problem was in the “uri_segment’, but I think 5 is the correct value:
I’ve missed something. Any idea?
thanks!
fanch