我可以将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"></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/