Home  >  Article  >  Backend Development  >  How to share values ​​between PHP HTML JavaScript MySQL codes_PHP Tutorial

How to share values ​​between PHP HTML JavaScript MySQL codes_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 15:15:19857browse

1.PHP

a.PHP -> HTML & JavaScript

It’s super simple, I have to write it too = =~

in the html code

/>
In the JavaScript code

copy the code and the code is as follows:



 b.PHP <-> MySQL

In the php code
copy the code The 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 method)

 html code
Copy code code As follows:






Copy the code
in the do.php file code as follows:

echo $_POST['count'];
?>

b. HTML -> JavaScript


JavaScript code (available, Can be changed)
Copy code The code is as follows:



3.JavaScript

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

 JavaScript code
Copy the code The code is as follows:




html code
Copy code The code is as follows:

b. JavaScript -> PHP

Transfer via html

1. The JavaScript code is first given to html
Copy code The code is as follows:



 2.html code to php
Copy code The code is as follows:





3.do.php receives
Copy code The code is as follows :

echo $_POST['count'];
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326107.htmlTechArticle1.PHP a.PHP - HTML lt;input type="" readonly="readonly" style='background -color:#DCDCDC' value=?php echo $perinfo[ID];? / Copy the code in the JavaScript code as follows: script type...