PHP static page displays Dynamic Content

Source: Internet
Author: User

Recently, when creating a website, you need to generate static pages. However, some content in the generated static pages must be obtained dynamically ..
Finally, I checked it online and added a summary .... Finally .. We will study it together .. Oh...
<SPAN class = "style1"> Application 1 </span>: Article Count to get Dynamic Content
Count page: Count. php CopyCode The Code is as follows: <? PHP
Require_once './global. php ';
$ Db-> query ("Update ". $ tablepre. "teacher set views = views + 1 where id = '". $ _ Get ['id']. "'");
$ Hello = $ db-> fetch_one_array ("select * from". $ tablepre. "teacher where id = '". $ _ Get ['id']. "'");
$ Hcount = $ Hello ['Views '];
?>
Document. Write ("<? = $ Hcount?> ");

Add it to the static page mk.html.
<SCRIPT src = "count. php? Id = <? = $ ID?> "> </SCRIPT>
Remember: The page path will change after the static count file is generated ..
<SPAN class = "style1"> Application 2 </span>: obtains dynamic information on this page, such as related articles.
Similarly, links in static pages are still in this form.Copy codeThe Code is as follows: <SCRIPT src = "read. php? Cid = <? = $ A ['code']?> "> </SCRIPT>

The content in read. php is as follows: Copy code The Code is as follows: <? PHP
$ Cid = $ _ Get ['cid'];
?>
Document. Write ("<Table cellspacing = 1 cellpadding = 8 width = 100% bgcolor = # c4cbce border = 0> ");
Document. Write ("<tr bgcolor = # ffffff align = center> ");
Document. Write ("<TD width = 33% align = center bgcolor = # ffffff> order number </TD> ");
Document. Write ("<TD> Grade </TD> ");
Document. Write ("<TD> time </TD> ");
Document. Write ("</tr> ");
<? PHP
$ Succquery = $ db-> query ("select * from". $ tablepre. "test where cid = '$ cid '");
While ($ succ = $ db-> fetch_array ($ succquery ))
{
?>
Document. Write ("<tr bgcolor = # ffffff align = center> ");
Document. Write ("<TD> <? = $ Succ ['id']?> </TD> ");
Document. Write ("<TD> <? = $ Succ ['city']?> </TD> ");
Document. Write ("<TD> <? = Date ('Y-m-d h: I: s', $ succ ['addtime'])?> </TD> ");
Document. Write ("</tr> ");
<? PHP
}
?>
Document. Write ("</table> ");
Document. Write ("<br> ");

another method:
static side: copy Code the code is as follows:




dynamic page:

fill in any thing that is dynamic without document. 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.