Hi PHP Help!
I’m hoping that after a long time searching I can finally get the answer I’ve been looking for. I’m not very good with code - I used to know it well, but after completely bombing Ruby on Rails, I hit a wall and it’s become difficult to learn/understand.
Anyways. I’ve been trying to build a content-based site now for the last few months. The only functionality I really need is to be able to change a global navigation menu and footer and have it reflect on all pages. After talking with some web people at work, they recommended I use PHP Include. After 2 months of doing Code Academy PHP courses and asking around, I feel like I’m ready to make an attempt at completing this site. However, I completely forgot about something and I’m glad I caught it before writing code up.
This is the general layout I’m trying to make: http://imgur.com/9Y349Kw
The way I currently have it structured is this: The header.php file contains the top black navigation menu, the title area where I’ll throw a graphic, and the green global navigation menu as well as the beginning of the HTML document with the main HTMlL/Body/Head tags. The white area right now is just set to a homepagecontent.php file - this is the part I’ll need to replace on other page. And then the bottom green bar and black footer area is in footer.php. My index.php contains the three files in order.
So I have 2 questions about this approach…1), how on earth do I include other pages? Obviously I can’t do an include for every single file because the homepagecontent.php will always be there unless I manually remove it, but then it affects the homepage. Plus, I haven’t named any future files yet (there could be several hundred pages on this site), so I don’t know how to set it up where it will accept future file names without having to constantly update the index.php page.
My second question is about linking them. I’m pretty sure I link them using this: index.php?p= - how does this work in this relationship with other pages? It kind of piles on from the first question.
Any help is appreciated. I would really appreciate any explanation if anyone posts code so I can really understand what’s happening rather than just copy+pasting since learning PHP will help me with my actual irl job (I do web and mobile usability :D). That’s one of the main reasons I want to make this site because learning some new code and refreshing myself on basic HTML/CSS will help.
Thanks so much everyone, can’t express how much I appreciate everything.