Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/264.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在所有行数据中放置下拉列表?_Php_Drop Down Menu - Fatal编程技术网

Php 如何在所有行数据中放置下拉列表?

Php 如何在所有行数据中放置下拉列表?,php,drop-down-menu,Php,Drop Down Menu,我在数据库中创建了虚拟数据,显示姓名和他们借用的仪器,旁边是可用仪器列表的下拉列表,如果他们想更改借用的仪器,但我不能将下拉列表放到其他行数据,我只对第一行数据做了操作,我希望所有行数据都有下拉列表,如何? 因此,我想您必须将查询更改为: $t="SELECT instrumentname from instruments where dateacquired='avail'"; $e=mysqli_query($con,$t); $select_optio

我在数据库中创建了虚拟数据,显示姓名和他们借用的仪器,旁边是可用仪器列表的下拉列表,如果他们想更改借用的仪器,但我不能将下拉列表放到其他行数据,我只对第一行数据做了操作,我希望所有行数据都有下拉列表,如何?



因此,我想您必须将查询更改为:

        $t="SELECT instrumentname from instruments where dateacquired='avail'";

    $e=mysqli_query($con,$t);
    $select_options = '<select name="inst">';
        while($f=mysqli_fetch_array($e)){
            $select_options .= '<option value="' . $f['instrumentname'] . '">'. $f['instrumentname'] .'</option>';
            }
$select_options .= '</select>';

    while($result=mysqli_fetch_array($r)){
        echo '<form method="post" action="">'; 
        echo '<input type="hidden" name="id" value='. $result['studentid'] 
        .'>';
        echo $result['studfname'] . " " . $result['studlname'] .
        " " . $result['instrumentname'] . " ";
        echo $select_options;
        echo '<input type="submit" value="submit" name="submit"><br>';
        echo '</form>';
    }
$t=“从dateacquired='avail'所在的仪器中选择仪器名称”;
$e=mysqli\u查询($con,$t);
$select_options='';
而($f=mysqli\u fetch\u数组($e)){
$select_options.=''.$f['instrumentname'].';
}
$select_选项='';
而($result=mysqli\u fetch\u数组($r)){
回声';
回声';
回显$result['studfname']。“.$result['studlname']。
“.$result['instrumentname']”;
echo$select_选项;
回声“
”; 回声'; }

试试看,希望它能有所帮助。

@黑暗凤凰我更新了我的答案,我想问题在于获取结果。我认为这种方式应该会更好。@dark phoenix我在
select
分组中犯了一个错误,请尝试更新的postLet。
        $t="SELECT instrumentname from instruments where dateacquired='avail'";

    $e=mysqli_query($con,$t);
    $select_options = '<select name="inst">';
        while($f=mysqli_fetch_array($e)){
            $select_options .= '<option value="' . $f['instrumentname'] . '">'. $f['instrumentname'] .'</option>';
            }
$select_options .= '</select>';

    while($result=mysqli_fetch_array($r)){
        echo '<form method="post" action="">'; 
        echo '<input type="hidden" name="id" value='. $result['studentid'] 
        .'>';
        echo $result['studfname'] . " " . $result['studlname'] .
        " " . $result['instrumentname'] . " ";
        echo $select_options;
        echo '<input type="submit" value="submit" name="submit"><br>';
        echo '</form>';
    }