click -6ren">
gpt4 book ai didi

php - 将 PHP 选择选项框值传递到另一个页面

转载 作者:太空宇宙 更新时间:2023-11-03 12:07:01 25 4
gpt4 key购买 nike

我正在尝试做的是当用户点击 php 选择选项时。然后它的值应该作为变量传递给另一个页面。

我有一个密码尝试。

<table>
<tr><td>
<?php
mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("member")or die(mysql_error());
$result = mysql_query("SELECT id,ugroup FROM ugroups");

?>

<select name='group' id='group' >
<?php
while ($line = mysql_fetch_array($result)) {
echo '<option value=' . $line['ugroup'] . '>' . $line['ugroup'] . '</option>';

}?>
</select>
<a href="db_sql/add_group.php?val=<?php echo $line['ugroup'];?>">click </a>
</td></tr>
</table>

这是add_group.php代码

  <?php
session_start();
ob_start();
include('../limoconfig.php');
if(!isset($_SESSION['adminuserid']) )
{
header('Location:../index.php');
}
else
{
if($_GET)
{
$ugroup = $_GET['ugroup'];
/*$id = $_GET['id'];*/

$acc_status = "update users set ugroup='".$ugroup."' where id=1931";
echo $acc_status;
$rate = db::getInstance()->exec($acc_status);
header('Location:../home.php');
}

}
?>

它不工作。

最佳答案

首先你需要把你的 table 放在里面然后您可以在单击 anchor () 时调用 ajax。

jQuery(document).ready(function($) {
var data='';
$("#group option:selected").each(function() {
if ($(this).attr('value') !== '') {
data=$(this).attr('value');
}
});
$("a").click(function() {
$.ajax({
type: "POST",
url: "file.php",
data: data,
beforeSend: function() {

$('body').css("opacity", "0.3");
},
success: function(response) {
alert(response);
},
complete: function() {
$('body').css("opacity", "1");
}
});
});

});

关于php - 将 PHP 选择选项框值传递到另一个页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26072106/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com