CodeIgniter Forums
Help creating pages from DB - 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: Help creating pages from DB (/showthread.php?tid=27554)



Help creating pages from DB - El Forum - 02-14-2010

[eluser]bondjp[/eluser]
Hi, i have the following problem:

I want to create dynamic pages like this: mysite.com/usertype/username
usertype and username are fields in the DB.

In my view i can extract the username like this:
Code:
<?php $usern=$row->username;
        $url_title = url_title($usern);?>
                        
    <?php echo anchor ($url_title,$usern);?>

I want to add a usertype to the link and create the page. Right now it says page not found(as it should say) and the url is like: mysite.com/username

Can some one shed some light on how i can do it?
Thanks.


Help creating pages from DB - El Forum - 02-15-2010

[eluser]kgill[/eluser]
read the userguide section on URI Routing, CI URL's use the following:

yoursite.com/controller_name/function_to_call/params_to_pass/

if you want it to be something other than that you need to specifically tell it how it should be handled.


Help creating pages from DB - El Forum - 02-15-2010

[eluser]bondjp[/eluser]
[quote author="kgill" date="1266282505"]read the userguide section on URI Routing, CI URL's use the following:

yoursite.com/controller_name/function_to_call/params_to_pass/

if you want it to be something other than that you need to specifically tell it how it should be handled.[/quote]

Hmm, i understand what you're saying with "controller_name/function_to_call/params_to_pass/".
My case is a bit different because i want to use data from the db to build the url.
Let me explain:

mysite.com/toyota/prius

toyota and prius are data that i extract from my db. So i'm not using any function or controller in my url.

Can someone tell me how to do it or point me in the right direction?
Thanks.


Help creating pages from DB - El Forum - 02-15-2010

[eluser]123wesweat[/eluser]
like kgill said look into http://ellislab.com/codeigniter/user-guide/general/routing.html

$route['toyota/prius'] = "get_car/toyota/prius";