PHP HTML JavaScript MySQL代码如何互相传值的方法分享
程序员文章站
2022-04-19 23:25:31
1.php a.php -> html & javascript 额 超简单,我也要写= =~ html代码中
1.php
a.php -> html & javascript
额 超简单,我也要写= =~
html代码中
<input type="" readonly="readonly" style='background-color:#dcdcdc' value=<?php echo $perinfo[id];?> />
javascript代码中
<script type="text/javascript">
var ability=<?php echo json($array);?>;
</script>
b.php <-> mysql
php代码中
<?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代码中
<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 文件代码中
<?php
echo $_post['count'];
?>
b. html -> javascript
javascript代码中 (可获得,可更改)
<script type="text/javascript">
var te = document.getelementbyid("count");
te.value = 1;
</script>
3.javascript
a. javascript -> html (通用法, 未验证)
javascript代码中
<script type="text/javascript">
function f(){
var id = "2";
var a = document.getelementbyid("a");
a.href.replace("(n)", id);
}
</script>
html代码
<a id="a" href="exportarticle.action?articles=(n)"/>
b. javascript -> php
通过html的转接
1.javascript代码先给html
<script type="text/javascript">
var i = 1;
var te = document.getelementbyid("count");
te.value = i;
</script>
2.html代码给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接收到
<?php
echo $_post['count'];
?>
a.php -> html & javascript
额 超简单,我也要写= =~
html代码中
<input type="" readonly="readonly" style='background-color:#dcdcdc' value=<?php echo $perinfo[id];?> />
javascript代码中
复制代码 代码如下:
<script type="text/javascript">
var ability=<?php echo json($array);?>;
</script>
b.php <-> mysql
php代码中
复制代码 代码如下:
<?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代码中
复制代码 代码如下:
<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 文件代码中
复制代码 代码如下:
<?php
echo $_post['count'];
?>
b. html -> javascript
javascript代码中 (可获得,可更改)
复制代码 代码如下:
<script type="text/javascript">
var te = document.getelementbyid("count");
te.value = 1;
</script>
3.javascript
a. javascript -> html (通用法, 未验证)
javascript代码中
复制代码 代码如下:
<script type="text/javascript">
function f(){
var id = "2";
var a = document.getelementbyid("a");
a.href.replace("(n)", id);
}
</script>
html代码
复制代码 代码如下:
<a id="a" href="exportarticle.action?articles=(n)"/>
b. javascript -> php
通过html的转接
1.javascript代码先给html
复制代码 代码如下:
<script type="text/javascript">
var i = 1;
var te = document.getelementbyid("count");
te.value = i;
</script>
2.html代码给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接收到
复制代码 代码如下:
<?php
echo $_post['count'];
?>
推荐阅读
-
PHP HTML JavaScript MySQL代码如何互相传值的方法分享
-
PHP HTML JavaScript MySQL代码如何互相传值的方法分享_php技巧
-
PHP HTML JavaScript MySQL代码如何互相传值的方法分享_PHP教程
-
PHP HTML JavaScript MySQL代码如何互相传值的方法分享_PHP
-
PHP HTML JavaScript MySQL代码如何互相传值的方法分享_php技巧
-
PHP HTML JavaScript MySQL代码如何互相传值的方法分享_PHP
-
PHP HTML JavaScript MySQL代码如何互相传值的方法分享
-
PHP HTML JavaScript MySQL代码如何互相传值的方法分享
-
PHP HTML JavaScript MySQL代码如何互相传值的方法分享