Home > php教程 > php手册 > body text

PHP HTML JavaScript MySQL代码如何互相传值的方法分享

WBOY
Release: 2016-06-13 11:57:27
Original
1216 people have browsed it

1.PHP

  a.PHP -> HTML & JavaScript

  额 超简单,我也要写= =~

  html代码中

/>
   JavaScript代码中

复制代码 代码如下:




  b.PHP MySQL

  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方式)

  html代码中

复制代码 代码如下:







  do.php 文件代码中

复制代码 代码如下:


echo $_POST['count'];
?>


  b. HTML -> JavaScript


  JavaScript代码中 (可获得,可更改)

复制代码 代码如下:




3.JavaScript

  a. JavaScript -> HTML (通用法, 未验证)

  JavaScript代码中

复制代码 代码如下:





html代码

复制代码 代码如下:




  b. JavaScript -> PHP

  通过html的转接

  1.JavaScript代码先给html

复制代码 代码如下:




  2.html代码给php

复制代码 代码如下:







  3.do.php接收到

复制代码 代码如下:


echo $_POST['count'];
?>

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template