How to pass values between php html JavaScript MySQL code

Source: Internet
Author: User
Tags mysql code

1. PHP

A. PHP-> HTML & JavaScript

The amount is too simple. I want to write = ~

Html code

<Input type = "" readonly = "readonly" style = 'background-color: # DCDCDC 'value = <? Php echo $ perinfo [ID];?> />
JavaScript code
Copy codeThe Code is as follows:
<Script type = "text/javascript">
Var ability = <? Php echo JSON ($ array);?>;
</Script>

B. PHP <-> MySQL

Php code
Copy codeThe Code is as follows:
<? Php
$ 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)

Html code
Copy codeThe Code is as follows:
<Form id = "form" name = "form" method = "POST" action = "do. php">
<Input type = "hidden" id = "count" name = "count" value = "1"/>
<Input type = "submit" name = "Submit" value = "Search"/>
</Form>

Do. php file code
Copy codeThe Code is as follows:
<? Php
Echo $ _ POST ['Count'];
?>

B. HTML-> JavaScript


JavaScript code (available, changeable)
Copy codeThe Code is as follows:
<Script type = "text/javascript">
Var te = document. getElementById ("count ");
Te. value = 1;
</Script>

3. JavaScript

A. JavaScript-> HTML (common method, not verified)

JavaScript code
Copy codeThe Code is as follows:
<Script type = "text/javascript">
Function f (){
Var id = "2 ";
Var a = document. getElementById ("");
A. href. replace ("(n)", id );
}
</Script>


Html code
Copy codeThe Code is as follows:
<A id = "a" href = "ExportArticle. action? Articles = (n) "/>

B. JavaScript-> PHP

Transfer through html

1. JavaScript code first give html
Copy codeThe Code is as follows:
<Script type = "text/javascript">
Var I = 1;
Var te = document. getElementById ("count ");
Te. value = I;
</Script>

2.html code to php
Copy codeThe Code is as follows:
<Form id = "form" name = "form" method = "POST" action = "do. php">
<Input type = "hidden" id = "count" name = "count" value = "1"/>
<Input type = "submit" name = "Submit" value = "Search"/>
</Form>

3. do. php received
Copy codeThe Code is as follows:
<? Php
Echo $ _ POST ['Count'];
?>

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.