gpt4 book ai didi

php - 如何获取选定的复选框值以在 PHP 中的 mysql 查询中使用

转载 作者:行者123 更新时间:2023-11-29 19:01:57 25 4
gpt4 key购买 nike

我可以将我的 MySQL 查询列为表。但我无法选择行值来使用另一个 MySQL 查询这是代码:

<?php
if(isset($_POST['btn_user'])) {
$username = $_POST['user'];
$sql_devicename = "SELECT users.id,
users.USER,
accounts.deviceid,
devices.name
FROM users
INNER JOIN accounts
ON users.id = accounts.userid
INNER JOIN devices
ON accounts.deviceid = devices.id
WHERE users.USER LIKE '%$username%'";

if($result_devicename = $mysqli->query($sql_devicename)){
if($result_devicename->num_rows > 0){
?>

<table>
<thead>
<tr>
<th data-field="id">Cihaz Adı</th>
<th data-field="id">Seçim</th>
</tr>
</thead>
<tbody>
<?php while($row = $result_devicename->fetch_array()){ ?>
<tr>
<td>
<?php echo $row['name'] ?>
</td>
<td>
<input type="checkbox" name="device_secret" id="<?php echo $row['deviceid']?>"/>
<label for="<?php echo $row['deviceid']?>"></label>
</td>
</tr>
<?php
}
$result_devicename->free();
} else{
echo "No records matching your query were found.";
}
} else{
echo "ERROR: Could not able to execute $sql_devicename. " . $mysqli->error;
}}?>
</tbody>
</table>
</div>
<div class="col s11"><blockquote>Init secret giriniz:</blockquote></div>
<div class="input-field col s11">
<i class="material-icons prefix">&#xE0DA;</i>
<input id="Secret" type="text" class="validate" name="secret" pattern="^([a-fA-F0-9]{16}|[a-fA-F0-9]{32})$" title="HEX değer, 16 yada 32 karakter">
<label for="Secret">Init Secret</label>
</div>

<div class="input-field col s11">
<button class=" btn-flat waves-effect waves-light right" type="submit" name="btn_secret">Güncelle
<i class="material-icons right">send</i>
</button>
</div>
</form>

<?php
if (isset($_POST['btn_secret'])){ ?>
echo $_POST['secret'];
}
?>

我想要什么?我想单击输出复选框之一 $row['deviceid']并写下一些输入值:

<input id="Secret" type="text" class="validate" name="secret" pattern="^([a-fA-F0-9]{16}|[a-fA-F0-9]{32})$" title="HEX değer, 16 yada 32 karakter">

在新的 MySQL 查询中使用。但无法获取所选行的值。出了什么问题?

最佳答案

而且,如果我像这样更改 php:

<?php
if (isset($_POST['btn_secret'])){ ?>
echo $_POST['device_secret'];
}
?>

我可以得到这个值。谢谢

关于php - 如何获取选定的复选框值以在 PHP 中的 mysql 查询中使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43805630/

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