Why do you sometimes want to write a complete PHP code separately?

Source: Internet
Author: User
See the code, I do not understand why a piece of complete PHP code to write separately? What if I put it 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 joins Tb_booktype BT on Book.typeid=bt.id joins 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) {
?>




No book information!






Add book information

}else{
?>


Reply to discussion (solution)

The part of the black part is the HTML code, not the PHP code
You can say that HTML is embedded in PHP, or HTML is embedded in the PHP
The advantage of this notation is that you can use visual HTML tools (such as DW) to observe and modify HTML parts

Together, the HTML part will be placed in the string. Because of the simultaneous existence of single double quotes, escaping causes visibility to degrade
If the custom delimiter is used, the aesthetics of the code is reduced due to the rule
You can also put in a separate file, include in. But leaving the visual space will affect the continuity of thought.

First of all, PHP is in the server solution, and HTML is in?? The solution of the device. php? is better than HTML first line.


Because it is not a PHP generation, so it should be divided into??? Php???
If you need to close up? The entire paragraph is PHP, in the HTML you want to use the echo of PHP??。

For example

 
  ';  Echo ';  Echo ' No book information! ';  Echo ';  Echo ';  Echo '
 
  
  
   
   
  ';  Echo '
  
   
   
      '; Echo ' 
     '; Echo ' 
    '; Echo ' 
   
';
';} Else{}?>

html+php Mixed Mode

With template smarty, PHP and HTML can be separated for easy maintenance.

I use SQL server2005, how should the query function (red part) be changed to use sqlsrv function to write?

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.