can't get link to work |
(03-25-2016, 03:05 AM)richie41 Wrote:(03-25-2016, 02:54 AM)Wouter60 Wrote: Be sure to name all controllers, libraries and models with a first capital letter. Maybe you should try other tutorials. Those that are made for beginners... Website: http://avenir.ro
(03-25-2016, 03:21 AM)Avenirer Wrote:I've followed this project through about 5 or more videos. I'm not giving up now(03-25-2016, 03:05 AM)richie41 Wrote:(03-25-2016, 02:54 AM)Wouter60 Wrote: Be sure to name all controllers, libraries and models with a first capital letter.
It may be confusing, but don't use capital letters in your hyperlinks or controller/function calls. Although the file names must be first-caps, CI will recognize which controller/function to call.
Is the details page not giving any error message anymore? Please try this: PHP Code: public function details($id) This should output the contents of your $data array, including the object or array that was returnd by your model. (03-25-2016, 03:23 AM)Wouter60 Wrote: It may be confusing, but don't use capital letters in your hyperlinks or controller/function calls. Although the file names must be first-caps, CI will recognize which controller/function to call. Just changed the link in products.php file in the VIEW folder to products/details/ then put your above code in the Products.php file in the CONTROLLERS folder. There is no error but it doesn't take me to the details page. It stay on the same page. It is supposed to load the details of a single game with a description and a photo. I have a header.php and a footer.php that's and then the details.php is supposed to lload in place of all the games. So it goes localhost/gamingplace then when you clikc on the link it supposed to load the details of the game you clicked on so it would be localhost/gamingplace/products(in the controller folder Products.php)/details(load the details function in the controllers folder Products.php)/1(id number of game pulled from database) Oh and by the way what does CI stand for. Also thanks for the help
Try this and see if it works, if not you have other problems in your code.
This is just a test link to see if it works: PHP Code: <?php echo site_url("products/details/1"); ?> What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(03-25-2016, 03:54 AM)InsiteFX Wrote: Try this and see if it works, if not you have other problems in your code. Tried that. And it still just stays on the same page with all the products instead of going to the details page of a single product. So I need to just try it with a normal page that doesn't pull in the header and footer and main content and just try static pages (03-25-2016, 03:23 AM)Wouter60 Wrote: Please try this: @richie41: What output you get when run above function? (03-25-2016, 05:46 AM)pdthinh Wrote:(03-25-2016, 03:23 AM)Wouter60 Wrote: Please try this: PHP Code: class Products extends CI_Controller{ PHP Code: $route['default_controller'] = 'products/details'; Changed the routes.php to 'products/details'. Took out all the php from details.php file in the VIEWS folder. And the details page loads. So the routes.php needs to be configured to show the get all products when the url is localhost/thegamingplace then when I click on one of the products the url should be localhost/thegamingpace/products/details/(whatever the id is) and should display the single product details.php page
Your product id needs to be passed to the controller from the view link.
It sounds like you are not passing the id to the controller, you can check the in the details method by doing a echo $id; exit; What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(03-25-2016, 12:59 PM)InsiteFX Wrote: Your product id needs to be passed to the controller from the view link. like this? PHP Code: public function details($id){ if I put the just put <a href="<?php echo $product->id; ?>"> as the link then it shows the correct id in the URL |
Welcome Guest, Not a member yet? Register Sign In |