Array doesn't seem to store my value

I am trying to output a random row of information from my database by using rand on the min, max of the ids in the database and in order to avoid duplicates I am trying to add that id to an array which I check before outputting the info. The problem is every time I call the function the array has a size of 0 despite it having a size of 1 at the end of the function. I’ve provided just the relevant snippet below. Any help would be much appreciated.

Edit – Apologies, it’s my first question asked on this site but I’m pretty sure I gave a clear problem statement. I’m not sure exactly what you want?

Edit 2- The original idea was to generate a random number (which correlates to the id of a database row), the random number was then checked against an array, if the number was in the array I get a new number, else add the number to the array and return the number to DisplayQuestion as the id of the row of the database.

 class MathQ {
    private $idCount;
    private $idMin;
    private $idMax;
    private $prevSeen = [];

    function DisplayQuestion() {
        $qId = $this->GetRandomQ();  
        $query = "SELECT * FROM questions WHERE `id` = '".$qId."'";
        $result = mysqli_query($this->link, $query);

        $row = mysqli_fetch_assoc($result);

        if($qId !== "-1"){
            echo "<p class='questionP' data-id='".$row['id']."'>".
        ($row['question'])."</p>";
        } else {
            echo "<p class='questionP'>No More Questions</p>";
    }

    // Think there is a problem with adding to the prevSeen array
    // Seems to reset back to 0 every time GetRandomQ() is called?
    function GetRandomQ() {
        $quesId = rand($this->idMin, $this->idMax);
        if(!$this->prevSeen) {
            $this->prevSeen[] = $quesId;
            return $quesId;
        } else {
            if(count($this->prevSeen) == $this->idCount){
                return "-1";
            }
            foreach ($this->prevSeen as $id) {
                if ($id == $quesId) {
                    $this->GetRandomQ();
                } 
            }
            $this->prevSeen[] = $quesId;  
            return $quesId;                    
        }
    }
}