PHP + js + html + mysql mutual pass-through Program

Source: Internet
Author: User
Tags mysql code

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 = ~

Html code

The Code is as follows: Copy code
<Input type = "" readonly = "readonly" style = 'background-color: # DCDCDC 'value = <? Php echo $ perinfo [ID];?> />

JavaScript code

The Code is as follows: Copy code
<Script type = "text/javascript">
Var ability = <? Php echo JSON ($ array);?>;
</Script>

B. PHP <-> MySQL


Php code

The Code is as follows: Copy code


<? 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

The Code is as follows: Copy code
<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

The Code is as follows: Copy code
<? Php
Echo $ _ POST ['Count'];
?>

B. HTML-> JavaScript


JavaScript code (available, changeable)

The Code is as follows: Copy code

<Script type = "text/javascript">
Var te = document. getElementById ("count ");
Te. value = 1;
</Script>

3. JavaScript

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

JavaScript code

 

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

Html code

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

PHP

Transfer through html

1. JavaScript code first give html

The Code is as follows: Copy code

<Script type = "text/javascript">
Var I = 1;
Var te = document. getElementById ("count ");
Te. value = I;
</Script> 2.html code to php

<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 receives

<? 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.