

Php echo html file code#
Anywhere in your code you could run "fetchData('weather') " and it would do all the database queries for you and return you the weather in one line without messing with the database in your logic code. In procedural programming you could have a single function that handles all the data stuff (admittedly this muddies the idea of MVC quite a bit) called "fetchData()". yeah)Įdit: Also if you don't have experience with Object-Oriented Programming the idea of "objects" can be confusing, especially when trying to wrap your head around MVC. "Hey lady, give me my medical records!" "Okay here they are!" She isn't the medical records - but she handles getting them and putting them away (as well as updating and deleting them but. You just need them so you ask her and she gets them. You have no idea her filing system or where they are and you don't care. Think of the model as the nice lady behind the window that fetches your files for you.

(The View has no clue what just happened and it doesn't care how the info got there, just that it needs to display it)
Php echo html file how to#
Once it has this information it gives it back to the controller in a nice simple format without the controller having to know anything about the storage system or how to access it.The Model goes into the database (or XML file or text file or whatever, doesn't matter) and runs all the queries needed to get this info for the controller.The controller has no access to the stored information so it asks the Model to grab it the last 3 hours of rainfall.The controller gets called up and is told it needs to display the weather.The controller controls the other two usually. The model is more of an object that handles the data in the database (or xml file, or mess of text files, or whatever you wish to store data in). I'm guessing Views is going to be mostly the markup (html, css), but what exactly is the model and the controller? Is the model my SQL database? or is it a link between my site and the SQL database? Is the controller basically the scripts? From what little I've described about my situation, does it sound like I'm heading in a bad direction? I've now read a ton about MVC and I'm just having a hard time understanding exactly what it is. I'm not sure if I've explained that well, if you wouldn't mind helping me out here, I could give a better example when I get home. Most of my pages basically check to see who the user is, then it pulls from my database certain variables and I use the include() function to grab the other parts of the page that will be viewed. I then have a folder where I have php scripts that insert cookies, login users, etc. I have a basic "template" I'm using, which is the html and css code for the head and formatting of my website. I'm probably 100% wrong in how I'm doing this, but let me explain how I have it setup.

Right now I have a webpage/site hosted from home. I don't quite follow your code since I've been procedurally writing all my PHP, but now I'm thinking I should move towards OOP. NET at work and have chosen to not bother with webforms and to try my hand at MVC 2. I'm a bit of a newb with PHP and this type of programming, I've been trying to figure out how/what MVC is. I'm happy this topic got posted, even happier for your response.
