I am trying to create a loop that displays each row in a table. I think I need to make an array out of the PK, but I can't figure out how to do that. Here is my code so far:

```
$conn = dbConnect('read');
$getData = 'SELECT * FROM table';
$allData = $conn->query($getdata);
if (!$allData) {
    $error = $conn->error;
} else {
    $data = $allData->fetch_assoc();
    $rowId = array($data['PK']);
} while ($rowId <= count($rowId)) {
    // code to be run for each row
    $rowId++;
}

```

EDIT: Sorry my question is confusing, I'm new to PHP.