如何从“选择选项”中隐藏特定值?

发布于 2024-12-13 12:14:24 字数 469 浏览 1 评论 0原文

我在 php 脚本中有一个选择框,它从 sql 数据库获取值并将其放置在选择下拉框中。

我的问题是:我只想隐藏数据库中显示在此下拉列表中的一项值。

在下拉框中,我有 3 个值:文件夹编号 1 - 文件夹编号 2 - 文件夹编号 3

我不想显示“文件夹编号 3”,并且无法从数据库中删除它。我只需要隐藏在这个选择框上。

我的脚本:

我有大约 10 个 php 页面:user.php、edit.php、admin.php 等...我只是想将其隐藏在 user.php 上,这样我就无法从数据库中删除或对所有人隐藏,我只能对user.php隐藏。

感谢您的帮助。

I have a select box in a php script that get values from sql db to place in a select dropdown box.

My problem is: I want to hide only one item value from my db that shows on this dropdown.

Inside dropdown box I have 3 values: folder number 1 - folder number 2 - folder number 3

I don't want to show "folder number 3" and I can't delete it from my db. I just need to hide on this select box.

my script:

<select name="upload_dir" id="upload_dir" >
<?php echo $upload_dirs?> // This PHP get item value from my SQL DB
</select>

I have like 10 php pages: user.php, edit.php, admin.php etc... I just want to hide it on user.php so I can't delete from db or hide for all, I can only hide for user.php.

Thanks for help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

苏辞 2024-12-20 12:14:24

您可以更新查询以不包含文件夹编号 3

select * from table where folder_number != 3

select * from table where folder_number not in (3)

或者在从查询中获取结果后执行此操作

foreach($folder_number as $key => $value){ 
   if($value['folder_number'] != 3){ 
      $upload_dirs .= '<option value="'.$value['folder_number'].'">Folder Number '.$value['folder_number'].'</option>';
   }
}

You can update your query to not include folder number 3

select * from table where folder_number != 3

or

select * from table where folder_number not in (3)

or after getting the result from the query do this

foreach($folder_number as $key => $value){ 
   if($value['folder_number'] != 3){ 
      $upload_dirs .= '<option value="'.$value['folder_number'].'">Folder Number '.$value['folder_number'].'</option>';
   }
}
渔村楼浪 2024-12-20 12:14:24

yoc 可以将其从 SQL 查询中排除:

SELECT * FROM folders WHERE folder_name != "folder number 3"

或将其从数组中删除:

foreach ($upload_dirs as $key=> $dir) {
    if ($dir == "folder number 3") {
        unset($upload_dirs[$key]);
    }
}

yoc can either exclude it from the SQL query:

SELECT * FROM folders WHERE folder_name != "folder number 3"

or remove it from the array:

foreach ($upload_dirs as $key=> $dir) {
    if ($dir == "folder number 3") {
        unset($upload_dirs[$key]);
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文