最佳答案 尝试像这样使用 foreach $sql22 = "SELECT * FROM -6ren">
gpt4 book ai didi

php - 从单个输入字段获取值

转载 作者:行者123 更新时间:2023-11-29 19:03:33 24 4
gpt4 key购买 nike

我无法将其转换为 $_POST 值,我该如何处理?所以基本上我想得到每个值。

<?php

require "scripts/db.ini.php";

$sql22 = "SELECT * FROM `category` WHERE `delete` = '0' AND `side` = 'right'";
//query
$query22 = mysqli_query($db,$sql22);
while($rows22 = mysqli_fetch_assoc($query22)){

$db_id = $rows22['id'];
$db_name =$rows22['name'];

echo "<input type='checkbox' name='$db_name' value='$db_id'>$db_name<br>";

}

?>

最佳答案

尝试像这样使用 foreach

$sql22 = "SELECT * FROM `category` WHERE `delete` = '0' AND `side` = 'right'";
//query
$query22 = mysqli_query($db,$sql22);
echo '<form action="" method="POST">';
while($rows22 = mysqli_fetch_assoc($query22)) {
foreach($rows22 as $row) {
echo '<input type="checkbox" name="'.$row['name'].'" value="'.$row['id'].'">'.$row['name'].'<br>';
}
}
echo '<input type="submit">';
echo '</form>';
echo '<pre>';
print_r($_POST);
echo '</pre>';

关于php - 从单个输入字段获取值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43684169/

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