I have the following code which selects ID's of a database with many regions in it. I create the array as follows:
$old2 = $this->query("SELECT regionid FROM theregions WHERE regionparent = '808'");
$old2_array = mysqli_fetch_array($old2);
And then I try and output the array like so:
while($row = mysqli_fetch_array($old2)) {
echo $row[0] . '<br>';
}
It produces the following:
800
834
933
However, if I use phpMyAdmin and run the same SQL statement, I get:
604
800
834
933
If I try using print_r(array_values($old2_array)); I get:
Array ( [0] => 604 [1] => 604 )
Have searched many SO pages, and have tried this:
$length = count($old2_array);
for ($i = 0; $i < $length; $i++) {
echo $old2_array[$i], "<br />";
};
...which produces:
604
Notice: Undefined offset: 1 in /index.php on line 128