I have a query which converts item rows of a series of IDs in MySQL table to columns, so the result has variable number of columns (VC). The only items that are not dynamic are the ID, FirstName, LastName. I know the number of variable items (n), which is part of the query.
what I want to do is to have a loop inside PHP while to add these variable columns to the PHP array.
something like this:
$someArray = [];
while($row = $result -> fetch_assoc()) {
array_push($someArray,[
'ID' => $row['EmployeeID'],
'FName' => $row['FName'],
'MName' => $row['MName'],
'LName' => $row['LName'],
-------Loop here --------
'VC1' => $row['VC1'],
'VC2' => $row['VC2'],
'VC3' => $row['VC3'],
'VC4' => $row['VC4'],
'VC5' => $row['VC5'],
..............
'VCn' => $row['VCn']
-------------------------
]);
}
I tried with PHP loop and could not figure out how to do it. Thanks for any help in advance.