davidsperling
asked on
How to add dynamic PHP content to static CSS layout example?
There are some nice layout examples in Chapter 8 in this bok - Web Designers Reference
http://www.friendsofed.com/download.html?isbn=1590594304
So, if some of the data comes from a database via php, what would the code look like?
Please provide some simple, conceptual snippets!
(In a non MVC style, I'll do that later ;-)
http://www.friendsofed.com/download.html?isbn=1590594304
So, if some of the data comes from a database via php, what would the code look like?
Please provide some simple, conceptual snippets!
(In a non MVC style, I'll do that later ;-)
ASKER
I know PHP/Mysql already :-) I have a working frame based site that looks like s-t. Now I want to remake it with a nice, proffesional CSS based layout!
(ie Chapter 8\08_p223_css_switchers in http://www.friendsofed.com/download.html?isbn=1590594304 )
I mean, how can I do without frames...?
How do you poulate a DIV from a php file or function for example?
Of course I have my own ideas, but I want to know how others do it :-)
( Sometime soon I'll rebuild the site according to Practical Web 2.0 Applications With PHP. OOP,MVC etc... But I'll have to release a site before that...)
(ie Chapter 8\08_p223_css_switchers in http://www.friendsofed.com/download.html?isbn=1590594304 )
I mean, how can I do without frames...?
How do you poulate a DIV from a php file or function for example?
Of course I have my own ideas, but I want to know how others do it :-)
( Sometime soon I'll rebuild the site according to Practical Web 2.0 Applications With PHP. OOP,MVC etc... But I'll have to release a site before that...)
ASKER
>Please provide some simple, conceptual snippets!
Or better yet, a site that explains the integration process!
Or better yet, a site that explains the integration process!
If you know PHP, you know that it can send any HTML to a web browser that you want -- even an entire HTML page can be written totally in PHP -- so sending code to a DIV is as simple as that below --
In other words, construct an HTML page as you want it to look, change the extension to .PHP, and use the
<?php php conditional tests here ?> (i.e. the angle bracket ? to delimit the PHP sections)
to allow for variable content, as MMDeveloper showed above.
Once you realize that a PHP file and an HTML file are essentially the same, it becomes incredibly simple.
In other words, construct an HTML page as you want it to look, change the extension to .PHP, and use the
<?php php conditional tests here ?> (i.e. the angle bracket ? to delimit the PHP sections)
to allow for variable content, as MMDeveloper showed above.
Once you realize that a PHP file and an HTML file are essentially the same, it becomes incredibly simple.
echo "<DIV id='" . $key . "'>\n <TR>\n";
echo "<TD width='60' bgcolor='f8f8f8' class='text' id='key1" . $key . "'>"
www.tizag.com/phpT/examples/formex.php/
ww.onlamp.com/pub/a/php/20 01/05/03/p hp_foundat ions.html
mgiseverything.co.uk/2008/ 06/06/php- html-templ ates/
www.faqs.org/docs/Linux-HOWTO/PHP-HOWTO.html
video.about.com/php/Using- PHP-With-H TML.htm
some links that I hope are not too simplistic for you.
ww.onlamp.com/pub/a/php/20
mgiseverything.co.uk/2008/
www.faqs.org/docs/Linux-HOWTO/PHP-HOWTO.html
video.about.com/php/Using-
some links that I hope are not too simplistic for you.
ASKER
Well I think I've found an acceptable solution... What about that?
//index.php
<!-- DDTs here -->
<?
//do some php stuff
//select $page="mypage.php"
?>
<html>
<!-- header -->
...
<div id="content">
<? require($page); ?>
</div>
...
<!--footer-->
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Here is how you would populate a select list assuming the database info has arleady been retrieved and processed into a single-dimension array
Open in new window