Pagination.. using multiple segment variables - 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: Pagination.. using multiple segment variables (/showthread.php?tid=12249) |
Pagination.. using multiple segment variables - El Forum - 10-12-2008 [eluser]Drayen[/eluser] Hey guys, kind of a dumb question here. Three types of fruit: Orange,Cherry,Apple mysite.com/cherry/5 That's how the uri segments would set up, so everything works fine but how would I program the controller to display ALL types of fruit? mysite.com/all/5 would not return any results, so is there a way to do an if statement where if the uri segment equals something specific it does something, or is there an easy way to automate this? Obviously the way I have it now, it uses the uri segment variable to access the database, but if there's no variable there it will break the pagination. Thanks for any help, sorry If I worded this poorly. Pagination.. using multiple segment variables - El Forum - 10-12-2008 [eluser]@li[/eluser] In mysite.com/cherry/5, is 'cherry' the name of a controller or a function, or are you routing it to your default controller? Pagination.. using multiple segment variables - El Forum - 10-12-2008 [eluser]Drayen[/eluser] [quote author="@li" date="1223819438"]In mysite.com/cherry/5, is 'cherry' the name of a controller or a function, or are you routing it to your default controller?[/quote] I just skipped all the other stuff, cherry isn't a controller or a function, it's just a variable mysite.com/index.php?/controller/cherry/5 That would be the full url Pagination.. using multiple segment variables - El Forum - 10-12-2008 [eluser]@li[/eluser] Well, then I don't understand your question fully. You want to display everything if the variable says all, right? So why don't you just do: Code: $option=$this->uri->segment(2); Pagination.. using multiple segment variables - El Forum - 10-12-2008 [eluser]Drayen[/eluser] [quote author="@li" date="1223851737"]Well, then I don't understand your question fully. You want to display everything if the variable says all, right? So why don't you just do: Code: $option=$this->uri->segment(2); That's what I was looking for, thanks Pagination.. using multiple segment variables - El Forum - 10-12-2008 [eluser]@li[/eluser] Np. By the way you should still validate the option before putting it inside a query. Something like: Code: if ($option !='cherry' && $option !='banana' && $option !='all') Pagination.. using multiple segment variables - El Forum - 10-12-2008 [eluser]Drayen[/eluser] [quote author="@li" date="1223852914"]Np. By the way you should still validate the option before putting it inside a query. Something like: Code: if ($option !='cherry' && $option !='banana' && $option !='all') Ah good idea, thanks! |