Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/77.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 sqlsrv fetch数组只返回1个结果(最近的),我知道有5个+;对于特定代码_Php_Sql - Fatal编程技术网

Php sqlsrv fetch数组只返回1个结果(最近的),我知道有5个+;对于特定代码

Php sqlsrv fetch数组只返回1个结果(最近的),我知道有5个+;对于特定代码,php,sql,Php,Sql,这是我的查询,它只提取最近添加的HOLDCODE。Armcode是患者id,Holdcode是两位数代码 $test = sql::query("select ARMCODE, HOLDCODE from ARE.AAS.ME where ARMCODE = 'ADSMANZS01'", $row['HOLDCODE']); if($test){ $data = sqlsrv_fetch_array($test); echo $data['HOLDCODE']; } 我是否需要对结果

这是我的查询,它只提取最近添加的HOLDCODE。Armcode是患者id,Holdcode是两位数代码

$test = sql::query("select ARMCODE, HOLDCODE from ARE.AAS.ME where ARMCODE = 'ADSMANZS01'", $row['HOLDCODE']);
if($test){
  $data = sqlsrv_fetch_array($test);
  echo $data['HOLDCODE'];
} 
我是否需要对结果进行foreach或for循环以使其全部回音或打印


如往常一样,任何帮助都将不胜感激。

使用while循环来迭代如下结果

  while ($data = sqlsrv_fetch_array($test);) {
      //perform your task
  }

是的,否则它只显示最后的结果。太好了,效果很好。我想我已经很快就明白了。非常感谢。我只是在等待7分钟的结束没问题。干杯Happ编码。