如何获取sql语句创建的所有输出?

This is my sql statement

SELECT TOWN_ID FROM TOWN WHERE CITY_ID = 1

output are : 4,5,6,7,67,887

In php my code is like this :

$temp = 1;
$sql = "SELECT TOWN_ID FROM TOWN WHERE CITY_ID = 1 = $temp";
$compiled = oci_parse($conn, $sql);
oci_execute($compiled);
$row = oci_fetch_array($compiled, OCI_ASSOC+OCI_RETURN_LOBS);
foreach ($row as $element ) 
{
  echo "
".$element."
";
}

My output is just 4 , how to get other outputs?

From the manual: Returns the next row from a query as an associative or numeric array

You need to call this function in a loop to get all records:

while ($row = oci_fetch_array($compiled, OCI_ASSOC+OCI_RETURN_LOBS))
{
  foreach ($row as $element ) 
  {
    echo "
".$element."
";
  }
}