HTML call PHP method

HTML itself cannot handle dynamic requests. To accomplish this, javascript is generally used. When generating static web pages, you can generate a corresponding javascript file reference to the html page according to the database id. For example, the page is 123.html, then generate a
<script type="text/javascript" src="click.php?id=123"></script>  on this page 

Then on the click.php page, just follow the php syntax to process the database.

==============================================

 

It is not possible to call the php file directly in the static page, but you can use the js calling method to call the php file, or use ajax to call the php file. 
Give a simple example to illustrate: Use the following code in the page a.html, you can pass the parameter of action=test to b.php. 
The Javascript code is as follows: 
<script type="text/javascript" src="b.php?action=test"></script>  
There is such a piece of PHP code in b.php: 
<?php
	$action=$_GET['action'];     
	echo "document.write('".$action."');n";    
?>
========================================

Guess you like

Origin blog.csdn.net/mjian178/article/details/112761001