jagguy Posted October 24, 2006 Share Posted October 24, 2006 If i want to display data with php from mysql. Also on the webpage I want a left and top menu and it requires some css/html.Having css,php and html all in the 1 webpage can look messy. I can do it by including the php script where it is requires in a div tag.Is there any easier or standard way to have 3 different code types on the 1 webpage? Quote Link to comment https://forums.phpfreaks.com/topic/24917-php-and-css/ Share on other sites More sharing options...
gmwebs Posted October 24, 2006 Share Posted October 24, 2006 The Model/View/controller (MVC) approach is pretty much a standard, although sometimes complex to implement. It basically means that you separate your content from your logic from your presentation. There are frameworks out there which will allow you to follow this approach, and it might be worth your while to have a look at what's out there. I have used CakePHP ([url=http://www.cakephp.org]www.cakephp.org[/url])and have found that to be sufficient for my needs, although it was quite a steep learning curve.Having said that, IMHO it is fine to have PHP and HTML in the same file as long as you try your best to make it readable, standards based, and use semantic markup. Also, try to do all the logic in one place, and then echo the result in the relevant HTML.For CSS, I would definitely stress that you use external stylesheets which can be linked to from within that file.For CSS, have a look at [url=http://www.w3schools.com/css/css_intro.asp]http://www.w3schools.com/css/css_intro.asp[/url]There are probably many schools of thought on this topic, but that's my 2p worth! Quote Link to comment https://forums.phpfreaks.com/topic/24917-php-and-css/#findComment-113676 Share on other sites More sharing options...
redbullmarky Posted October 24, 2006 Share Posted October 24, 2006 yeah - if mess is a prime concern, then something along the MVC road is gonna help tonnes. I personally like CodeIgniter (www.codeigniter.com) as it's pretty lightweight and only includes what you use. If you're after something a little more simple, then try templating using a template engine. Smarty seems to be the most popular, but I find it trickier to use than many. there's a simple one here, with an explaination of why i didn't choose smarty: http://www.massassi.com/php/articles/template_engines/ and another recommendation is here: http://phpsavant.com/yawiki/Whichever you choose, the end result is seperation of your business logic from your presentation - leaving a set of nice clean HTML documents and a set of nice PHP scripts. Quote Link to comment https://forums.phpfreaks.com/topic/24917-php-and-css/#findComment-113691 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.