好吧,我很困惑。参见下面的代码。
它将所有字符正确加载到列表中。
我从来没有收到任何错误。
然而,有些东西并没有真正起作用。因为我选择哪个字符并按select character并不重要,它总是在数据库中通过名称“superadmin”检索字符。我以为这可能是一个会话搞砸了,但我没有登录到帐户上的字符超级管理员。你知道我哪里搞砸了吗s
<!-- START: Load all characters from database, and put them in dropdown -->
<form method="post" action="admin_settings.php">
<input type="hidden" name="slct_id">
<select name="names">
<option value = "">---Select---</option>
<?php
$stmt = $mysqli_0001->prepare("SELECT role_name FROM mugame_0001.mu_role");
$stmt->execute();
$stmt->bind_result($slct_name);
while ($stmt->fetch()){
echo "<option value='$slct_name'>$slct_name</option>";
}
$stmt->close();
?>
</select>
<input type="submit" name="indoc_dochrselect" value="Select Character">
</form>
<!-- END: Load all characters from database, and put them in dropdown -->
<div class="nk-gap-2"></div> <!-- Creates a neat gap between the two thingie-mackdodies $ -->
<!-- START: Load character information based on the selected character -->
<?PHP
if (isset($_POST['indoc_dochrselect'])) {
$slct_id = $slct_name;
//$id = $_POST['id'];
if ($stmt = $mysqli_web->prepare("SELECT * from mugame_0001.mu_role WHERE role_name = ?")) {
$stmt->bind_param("s", $slct_id);
$stmt->execute();
$res = $stmt->get_result();
$data = $res->fetch_all(MYSQLI_ASSOC);
foreach ($data as $row)
{
echo "<form action='php/mysqli_action_admin.php' method='post'>";
echo "<input type='text' class='form-control' name='char_name' placeholder='" . $row['role_name'] . "'>";
echo "<input type='text' class='form-control' name='char_level' placeholder='" . $row['role_level'] . "'>";
echo "<input type='text' class='form-control' name='char_money' placeholder='" . $row['money'] . "'>";
echo "<button class='nk-btn link-effect-4 float-right' name='do_adm_getinfo_selected_role_update'>Update Character</button>";
echo "</form>";
}
}
}
?>
<!-- END: Load character information based on the selected character -->
1条答案
按热度按时间mwkjh3gx1#
绑定的结果变量
$slct_name
是流动的缩编。这似乎是罪魁祸首:
$slct_id = $slct_name;
您使用的是最终获取的值,但我相信您希望使用发布的值。我假设最终获取的值是
SUPERADMIN
.我相信你想用
$_POST['names']
因为这是select字段中的name属性。