0

I am trying to fetch the values of a column in PHP and I am not sure why it is fetched at random. In the table, they are ordered from 1 to 5 and when I echo I get 14253. I have a similar function for another column and it works great, same as this one. Did I do something wrong?

public function getSKUProducts() {
        $sql = "SELECT SKU FROM Product_table";
        $stmt = $this->connect()->query($sql);
        $array = Array();
        //get data from db
        while($row = $stmt->fetch_assoc()) {
            echo $row['SKU'];
            $array[] =  $row['SKU'];  
        }
        return $array;
    }

Stephano.
  • 3
  • 1

0 Answers0