only pull one row from db to display problem |
[eluser]dadamssg[/eluser]
Im just trying to display one row of information on a page and i keep getting a 404. I'm using an 'events' controller and im trying to pull the second segment of the uri as the event id number to query. heres my event controller Code: class Events extends Controller { and heres my view Code: <?php my head_view just opens up the html Code: <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
[eluser]dadamssg[/eluser]
oh and heres the model im using Code: <?php
[eluser]Craig A Rodway[/eluser]
If you read the documentation, you will see there is a function for returning one row - look for row().
[eluser]dadamssg[/eluser]
well now ive learned that its not that. Its that i can't get the uri segment. For whatever reason i just can not assign the 3rd uri to anything. the uri im trying to capture is the number like below mysite.com/events/867 im trying to use to get it but won't work Code: $id = $this->uri->segment(2); and i know i have an event with an id of 867 so thats why i used that number. When i go to mysite.com/events/ it pulls up that event like its suppose to but if i try to add a third segment with another event id, say 868(which is also in the db), it pulls up a 404
[eluser]Craig A Rodway[/eluser]
In that case, you should read the page about URLs in the user guide. Quote:The first segment represents the controller class that should be invoked. From your example, mysite.com/events will call the index function of the event controller - which will work OK. But when you try to go to mysite.com/events/868, it will not work because the 868 function doesn't exist in the events class. You have two options - make the URL include index mysite.com/events/index/868; or add a manual route like this using Routing. Code: $route['events/(:num)'] = 'events/index/$1';
[eluser]dadamssg[/eluser]
awesome, THANK YOU. its working now and i understand that now. |
Welcome Guest, Not a member yet? Register Sign In |