php和mysql的行为方式与html和css的div标签相同吗? [关闭]

I know its a bit of a tricky question but like the information about the div tag in the html file is actually in the css file, can you do the same with php and mysql?

I know its had dot understand so heres an example!

So you have:

HTML file: <div class="box"></div>

CSS file: .box {height:20px; width: 20px;}

Then speaking of PHP and MYSQL. If I want to display mysql results on a 'page.php' can I have a 'div' like tag that shows where I want the results to be displayed but have the mysql code actually in another file?

Thanks!

James

That's certainly a strange way of looking at it.

I think the concise answer is yes, though it is much easier to think of it without any of that html css talk.

Look into something like the smarty template system:

http://www.smarty.net/

for a way to have logic and output in separate files. Mind you I only refer you to smarty because it is a commonly used package and NOT - I repeat - NOT because I approve of the software.

Basic understanding of PHP will easily reveal any number of ways to achieve what you speak of here. It's pretty simple.

You use the <div><?php .... ?></div> tag to go get the information you want inside of that div tag.

The .... could be a function, or the whole set of code you need to connect, query and display your data.

PHP allows you to include other PHP files, which would allow you to put database specific pieces of code in one file and the rest of what you're doing elsewhere.

http://www.w3schools.com/php/php_includes.asp