Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRyan O'Connor
11,282 Pointscompile multiple pages with unique content
I'm building an informative website. I have a page that lists 'courses' or 'tracks' which come from an associative array. I want those tracks to go to a 'details' page. I want the details page to compile the HTML for me but I can't figure out how to store the information.
I could......
1) create a new course.php in the dir for each course. But that seems time consuming.
2) create an array that contains the HTML as a value
3) create a database that contains the HTML
What is the best way to store the HTML and call it to a 'details' page?
1 Answer
Sergey Podgornyy
20,660 PointsBest solution for this is to create a database in which you will store info about all tracks. Because your array will grow up in time and it will be harder to iterate through it with each time and although work with it.
For example you can create page called all_Tracks.html which contain buttons(lets just call it buttons :) ) with name of the tracks. If you press on any button(which will contain link like this http://localhost/details.php?course=PHP) it will redirect you to a page called details.php?course=name. After that you can get course name from $_GET['course'] and send query to the database for info about this course. Depending of what you received from query you will display the result using same styling but with different colors and text that are suitable for track. And there is no need to use multiply pages.
It isn't an ideal example of how it should be. But it will help you learn new things and technologies ;)