https://stackoverflow.com/questions/26415596/mysqli-fetch-array-returning-only-one-result
mysqli_fetch_array is only return one row of data from your selected table
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have an issue where I have a function like this which outputs:
while ($row = mysqli_fetch_array($sql_result)) {
$division_name = stripcslashes($row['name']);
return $division_name;
}
This works to fetch a single value, but it doesn't when I need multiple values from the query. (in that case it only returns the first match row).
If I substitute return for echo, I get unexpected behaviour from my view.
How can I structure my code so that when I call this function, it outputs multiple values properly.
Thanks
Please or to participate in this conversation.