Php 从表中选择值!=数组中的值

Php 从表中选择值!=数组中的值,php,arrays,select,option,Php,Arrays,Select,Option,从1到10的数组 我想下拉选择数组中的值,排除数据库表中的值 例如:id=3在表==>下拉选项中(1,2,4,5,6,7,8,9,10) 例如:id=4在表==>下拉选项中(1,2,3,5,6,7,8,9,10) 选择 $no=数组(1,2,3,4,5,6,7,8,9,10); foreach($no as$key): $hh=“选择*从警报服务器,其中警报服务器否不是$否”; $stmt=sqlsrv_查询($connect,$hh); 回音“.$hh.”; endforeach; 回声'

从1到10的数组 我想下拉选择数组中的值,排除数据库表中的值 例如:id=3在表==>下拉选项中(1,2,4,5,6,7,8,9,10) 例如:id=4在表==>下拉选项中(1,2,3,5,6,7,8,9,10)


选择
$no=数组(1,2,3,4,5,6,7,8,9,10);
foreach($no as$key):
$hh=“选择*从警报服务器,其中警报服务器否不是$否”;
$stmt=sqlsrv_查询($connect,$hh);
回音“.$hh.”;
endforeach;
回声'

在查询中,您需要使用$key而不是$no

$hh="select * from Alert_Severtiy where Alert_Severtiy_No Not <>$key";

然后循环返回的结果。

您能修复代码的可见性吗?您好!请尝试修复代码的格式,至少尝试问一些与问题稍有相似的问题,以便我们可以帮助您!
$hh="select * from Alert_Severtiy where Alert_Severtiy_No Not <>$key";
$here = implode(",", $no);
$hh="select * from Alert_Severtiy where Alert_Severtiy_No Not IN ($here)";