Php foreach选择选项错误检索水平数据

Php foreach选择选项错误检索水平数据,php,mysqli,Php,Mysqli,当我从数据库检索数据时出现问题,结果是 如何正常检索数据 这是我的密码 $wewqry = $mysqli->prepare("SELECT itemname from table_item "); $wewqry->execute(); $wewqry->bind_result($itemname); $wewqry->store_result(); while ($wewqry->fetch()){ $table = array("itemname"

当我从数据库检索数据时出现问题,结果是

如何正常检索数据

这是我的密码

$wewqry = $mysqli->prepare("SELECT itemname from table_item ");
$wewqry->execute();
$wewqry->bind_result($itemname);
$wewqry->store_result();

while ($wewqry->fetch()){
    $table = array("itemname" => $itemname);
    foreach ($table as $t => $w){
        echo '<select name="itemname">';
        echo "<option>$w</option>";
        echo '</select>';
    }
}
$wewqry=$mysqli->prepare(“从表中选择项目名称”);
$wewqry->execute();
$wewqry->bind_result($itemname);
$wewqry->store_result();
而($wewqry->fetch()){
$table=数组(“itemname”=>$itemname);
foreach($t=>w的表格){
回声';
回声“$w”;
回声';
}
}

您不应该每次通过循环创建一个新的
,而是在循环外创建一次:

echo '<select name="itemname">';
while ($wewqry->fetch()) {
    echo "<option>$itemname</option>";
}
echo '</select>';
echo';
而($wewqry->fetch()){
回显“$itemname”;
}
回声';
您也不需要为获取的每一行创建一个数组。只需将结果变量直接插入
echo
语句。

什么是水平?