This article introduces how to pass values between PHP, HTML, JavaScript, and MySQL codes. For more information, see 1PHPaPHP-HTML and JavaScript ~
This article introduces how to pass values between PHP, HTML, JavaScript, and MySQL code. if you need to learn more, refer
1. PHP
A. PHP-> HTML & JavaScript
The amount is too simple. I want to write = ~
The example code in html code is as follows:
- />
JavaScript code
The instance code is as follows:
- Var ability = ;
- Script
B. PHP <-> MySQL
The instance code is as follows:
- $ Dbcnx = @ mysql_connect ("localhost", "root", "1234 ");
- If (! $ Dbcnx ){
- Echo ("Unable to connect to the". "database server at this time .");
- Exit ();
- }
- If (! @ Mysql_select_db ("pms ")){
- Echo ("Unable to locate the joke". "database at this time .");
- Exit ();
- }
- Mysql_query ("set names 'gb2312 '");
-
- $ Q = mysql_query ("select * from ability where ALV = 1 ");
- While ($ row = mysql_fetch_array ($ q )){
- $ Array1 [] = $ row [AName];
- }
- ?>
2. HTML
A. HTML-> PHP (POST mode)
The instance code is as follows:
Do. php file code
The instance code is as follows:
- Echo $ _ POST ['count'];
- ?>
B. HTML-> JavaScript
JavaScript code (available, changeable)
The instance code is as follows:
- Var te = document. getElementById ("count ");
- Te. value = 1;
- Script
3. JavaScript
A. JavaScript-> HTML (common method, not verified)
JavaScript code
The instance code is as follows:
- Function f (){
- Var id = "2 ";
- Var a = document. getElementById ("");
- A. href. replace ("(n)", id );
- }
- Script
The instance code is as follows:
- "A" href = "ExportArticle. action? Articles = (n) "/> B. JavaScript->
PHP
Transfer Through html
1. JavaScript code first give html
The instance code is as follows:
- Var I = 1;
- Var te = document. getElementById ("count ");
- Te. value = I;
- Script 2.html code for php
- 3. do. php received
- Echo $ _ POST ['count'];
- ?>