Why do I need to write a complete php code separately? At last, this post was edited by u014060468 from 2014-06-2009:53:43. for details, see the code. why do I need to write a complete php code separately? What if I write together? & Lt ;? Phpinclude (Connconn. php); $ querymysq why is a complete php code sometimes written separately?
This post was last edited by u014060468 at 09:53:43
Seeing the code, I don't understand why I want to write a complete php code separately? What if I write together?
Include ("Conn/conn. php ");
$ Query = mysql_query ("select book. barcode, book. id as bookid, book. bookname, bt. typename, pb. pubname, bc. name from tb_bookinfo book join tb_booktype bt on book. typeid = bt. id join tb_publishing pb on book. ISBN = pb. ISBN join tb_bookcase bc on book. bookcase = bc. id ");
$ Result = mysql_fetch_array ($ query );
If ($ result = false ){
?>
} Else {
?>
------ Solution --------------------
The Black part is html code, not php code.
You can say that html is embedded in php, or php is embedded in html.
The advantage of this writing method is that you can use visual html tools (such as DW) to observe and modify the html part.
In combination, the html part should be placed in the string. Because a single double quotation mark exists at the same time, escaping reduces visibility.
If custom delimiters are used, the code will be less elegant due to the rule.
You can also put it in a separate file and include it in. However, leaving the visual space will affect the continuity of thinking.
------ Solution --------------------
First, php is implemented in the server, while html is implemented in the server. Php will run better than html.
Because the middle stage is not the php generation, we need to split two php versions to compile
If you need to combine the entire part of php, you need to use php echo to compile the html.
For example
Include ("Conn/conn. php ");
$ Query = mysql_query ("select book. barcode, book. id as bookid, book. bookname, bt. typename, pb. pubname, bc. name from tb_bookinfo book join tb_booktype bt on book. typeid = bt. id join tb_publishing pb on book. ISBN = pb. ISBN join tb_bookcase bc on book. bookcase = bc. id ");
$ Result = mysql_fetch_array ($ query );
If ($ result = false ){
Echo'
';Echo'
';Echo'
No book information! | ';Echo'
';Echo'
';
Echo'
';Echo'
';Echo'
'; Echo 'add book information | ';Echo'
';Echo'
';
} Else {
}
?>
------ Solution --------------------
Html + php mixed encoding mode
The template smarty can be used to separate php and html for easy maintenance.