在php中通过while循环读取和比较数据


read and compare data through a while loop in php

我使用oracle数据库和php,我想从一个表中选择一个字段的所有值。然后在while循环中比较它们,找出最大的一个(它们是数字)。我该怎么办?我将显示我的代码:

$dql="SELECT T21_5 FROM T21";
$dqlresult=oci_parse($conn,$dql);
oci_execute($dqlresult);
$rew=oci_fetch_assoc($dqlresult);
$max=0;
while($rew){
  if($max>$rew['T21_5']){
     $max=$max;
  }else{
     $max=$rew['T21_5'];
  }
}

只存储最大值

$max=0;
while($row){
  if($max < $row['T21_5'])
  {
     $max=$row['T21_5'];
  }
}
echo $max;//This will output the max value