![]() |
How can Do this in Pagination - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: How can Do this in Pagination (/showthread.php?tid=11391) |
How can Do this in Pagination - El Forum - 09-06-2008 [eluser]phantom-a[/eluser] I need to turn this into pagination. This code works, but will display all my results on the same page, I need into pagination.. Code: $data['query'] = $this->db->query('SELECT * FROM `table` WHERE `category`=1 ORDER BY date'); How can Do this in Pagination - El Forum - 09-07-2008 [eluser]exodus7[/eluser] From what I can tell you should use Code: $this->db->get_where() Code: $this->db->get() Code: $query = $this->db->get_where('links', array('category' => 1), $num, $offset); Let us know if this works ![]() How can Do this in Pagination - El Forum - 09-07-2008 [eluser]phantom-a[/eluser] It works! it works :lol: The last problem is also I need a ORDER by statment, but still thanks for help. There is method called get_where_orderby is there? How can Do this in Pagination - El Forum - 09-07-2008 [eluser]Sumon[/eluser] You can use Code: $this->db->orderby("date" , "asc"); How can Do this in Pagination - El Forum - 09-07-2008 [eluser]phantom-a[/eluser] [quote author="Sumon" date="1220788050"]You can use Code: $this->db->orderby("date" , "asc"); I've tried that one too, I does not alter the table for reason. I don't think any data is actually getting passed to it. Well this my complete code. It works 99% except it loads the rows in the wrong order. its showing the oldest one's first, thats I why I want too use ORDER BY and reverse the order, but it does not work. ![]() *controller Code: function cgi_proxies() //Loads the cgi_proxies/index.php/go/cgi_proxies *the model class "cgiproxies_model" Code: class cgiproxies_model extends Model { How can Do this in Pagination - El Forum - 09-07-2008 [eluser]Sumon[/eluser] By the way here is my custom pagination. you may try it. Here is my controller code Code: $this->load->model("asknanny_model");//my model Here is the view (only pagination link and record portion) Code: Displaying <?=$DisplayStartVal?>-<?=$DisplayEndVal?> out of <?=$TotalRecord?>(Page<? if($TotalRecord>0) echo $CurListing; else echo "0";?>) I shall highly appreciate if i get some feedback of this pagination. How can Do this in Pagination - El Forum - 09-07-2008 [eluser]phantom-a[/eluser] I'm not sure what I do with your pagination. I"m not seasoned programer that doesn't make any sense to me barely. I am only a little green in php as the moment.. How can Do this in Pagination - El Forum - 09-07-2008 [eluser]Sumon[/eluser] i am really sorry. the time when i write pagination post, you write your third reply. sorry i post late and have not check before posting. How can Do this in Pagination - El Forum - 09-07-2008 [eluser]phantom-a[/eluser] It appears I solved my problem. You can join methods so I put Code: $data['result'] = $this->db->order_by('datestamp','desc')->get_where('links', array('category' => 1),$limit,$offset); and now it works , showing the newest first, where category=1 ![]() How can Do this in Pagination - El Forum - 09-07-2008 [eluser]Sumon[/eluser] Lets have a close look the following line of codes Code: $all_result_set = $this->cgiproxies_model->get_cgiproxies('',$config['per_page'],$this->uri->segment(3)); Seems to me you have written $this->db->orderby("datestamp" , "desc"); in wrong place. Try to place it in model function get_cgiproxies(...... Let us know what's going on.. |