I need to arrange the SQL results in PHP as follows:
if (!$result) {
echo "An error occurred.\n";
exit;
}
while($array = pg_fetch_array($result)) {
$list = $array['list'];
}
pg_free_result($result);
But only pedro is returned in the array.
You need pg_fetch_assoc() to get the returned associative array.
And you need to build an array to append the nodes:
$lists = []; while ($row = pg_fetch_assoc($result)) { $lists[] = $row['list']; }Or if you just want to play around, you can use pg_fetch_all_columns().
https://www.php.net /manual/en/function.pg-fetch-all-columns.php
0 represents the first column in the row.