homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Three layer application

5+ Year Member

Msg#: 4117052 posted 6:58 pm on Apr 16, 2010 (gmt 0)

I'm trying to build a site using the 3 layer concept of data, application and presentation but I'm getting confused in the detail.

When there is a lot of dynamic content the application layer will be generating data for the presentation layer depending on the input from a user.

So for instance a search page result may have 4 results or 10. Usually I would loop the array fetched from SQL and the html would be added to in each loop cycle with the correct data either by a direct echo or appending a variable to be echo later in the program.

This of course means that there is html code in the application layer.

There seems no way around this as I have to produce 4 blocks of html sometimes 10 blocks of html and so on.

Is this concept just a myth or am I missing something?



WebmasterWorld Senior Member 10+ Year Member

Msg#: 4117052 posted 4:56 pm on Apr 17, 2010 (gmt 0)

Is your design object-oriented? If you use simple data objects to represent the data in the rows, you would load the data into those objects and pass the objects to the presentation layer. Here you would loop through the objects and mix their data fields in with the HTML code.


5+ Year Member

Msg#: 4117052 posted 11:11 am on Apr 18, 2010 (gmt 0)

Won't that result in more code though slowing the app down, I can see the point when a lot of pre-formatting of the data has to occur but say you just wanted to retrieve a short list from a database and present that accordingly with no data formatting then would this be over doing it?


5+ Year Member

Msg#: 4117052 posted 11:28 am on Apr 18, 2010 (gmt 0)

Another thing is a lot of page elements rely on conditionals depending on the data, they would still have to remain on the presentation page

Leaving the presentation page full of loops and conditionals and only really removing the database call.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved