Using GET for one universal page layout and content

this question is sort of related to my other post: Is PHP suited for large-scale Enterprise?

Most of the websites I have built have not been large and not dynamic in nature, but I need to make one now with a boatload of content on it. and I’m needing a little resource help where I can research something. I’m sure a lot of developers do this, and I know I need a massive database or 2 and the PHP knowledge I already have, but I’m just looking for a little guidance about how to do this the easiest way. It may actually sound like a stupid question and I might be over-thinking a bit. So…

Lets say I have 500 articles that I want to make available to a site visitor and give them the option to choose what they want to look at through nav menus and submenus. I want the same page to display to the user, regardless of what article is chosen. Assuming I’ve got the talent to write the HTML/CSS/JS to provide the meat and potatoes for the page layout and interaction, how does PHP play a part in that? Would I be right by saying the following?

If the home page had this content on it:

This website is a course in PHP coding. <a href="courseTemplate.php" target="_blank">Click here</a> to view course #1.

and I wanted all the course content to be displayed through the use of the “courseTemplate.php” file, how simple is that? I would assume that these types of things would be the results and the techniques to accomplish the goal, right?

=> a resulting URL that looks like this:

www.site.com/courseTemplate.php?id=1

=> storing all the text of the course material in one single field of a DB record. NOT storing the layout-oriented code (HTML, etc.) and echoing it out with the rest of the text.

=> making use of the GET() function somehow to pull the course’s text content out of the database.

Can someone show me a website that demonstrates this? I don’t think this is a very difficult concept to grasp, and I’m sure there are web resources available that show how this is done. I’m almost sure that most news agency websites do this, and I know for a fact that most forum software has this template technique written into it, regardless if SEO is included or not. Sorry for the basic nature of this question. I know some of my previous posts have been such where I’ve asked much more difficult questions than this. I have seen youtube tutorials on issues similar to this, but nothing pulled up by google really shows this in a very simplistic nature. thanks.

Adam

Hi Adam,
I’m not the most experienced in php but this is what I know; I believe that php would be responsible for showing the article corresponding to the GET request made. Take this for example:

<?php
if($_GET["id"] == 1) {
    //show article 1
 } 
?>

This is only a proof of concept and like I say, I’m not the most experienced in php. You could maybe even do it so that the id is fed directly into the database and then the article is displayed directly from that. This could open you up to an SQL Injection attack however.

My response might not have been helpful or it might have been. Other people will likely have a better response as they are more equipped to do so.
Many thanks,
HTT5041

You could maybe even do it so that the id is fed directly into the database and then the article is displayed directly from that.

so obviously you’re saying that 100% of the text of the article is kept in the DB, right? what about actual front end code? is front end code ever stored in a database and echoed out with PHP? or is that bad practice and against programming standards? I would assume the latter.

Well, I’ve never tried to store the text in a database but I don’t see why that wouldn’t work. Personally, I would have it like I showed in my code snippet but that might be against your specification. The issue I could see with storing the article in a database is that it might be hard to format the text in a certain way, say font sizes with HTML and CSS as that would all have to be in the database entry too, but then again it is possible.

In my opinion, it is all about how it is displayed to the user, having it stored in the database might be complicated to code and throw out some errors whereas having all articles on the same page but only the requested one is displayed is easier as they are all in one place. Both options would result in similar user experience.

Many thanks,
HTT5041.

someone once told me that storing front end code in a db and echoing it out with server languages is a complete no-no. instead of that, he told me I should delve into something like this:

apparently that is very popular in creating websites that have massive amounts of content on it in the form of articles being displayed on a central page that is layed out in a template-oriented manner. like this page:

what do you think about that? I suppose there are many ways to do just about everything. But I absolutely hate complexity, which is why this question was asked to begin with. I’m not even really a programmer by nature, and I think stuff like CSS Bootstrap that comes from high quality educational institutions like MIT makes things overly complex for little people that don’t have the time to sit around and think stuff up in the form of huge framework brainchilds of PHD students. =(

Sponsor our Newsletter | Privacy Policy | Terms of Service