Chromosome Locus Variant_A Variant_B Variant Strain_ID Family Parent1_Name Parent1_Marker Parent2_Name Parent2_Marker Line Marker Gid
----------------------------------------------------------------------------------------------------------------------------------------------------------------
Gm09 40907915 G A GA DS11.46096 46 IA3023 AA PI507.681B* BB 96 BB 2
Gm09 422384 G A GA DS11.46096 46 IA3023 AA PI507.681B* BB 96 AA 4
Gm09 422720 A G AG DS11.46096 46 IA3023 BB PI507.681B* AA 96 BB 5
Gm09 424439 C A CA DS11.46096 46 IA3023 AA PI507.681B* BB 96 AA 7
Gm09 425375 G T GT DS11.46096 46 IA3023 AA PI507.681B* BB 96 AA 9
Gm09 425581 T C TC DS11.46096 46 IA3023 BB PI507.681B* AA 96 BB 10
Gm09 43921862 C A CA DS11.46096 46 IA3023 BB PI507.681B* AA 96 AA 12
I've the table shown above. I need the following output:
| Strain | | Gm09_40907915 | Gm09_422384 | Gm09_422720 | Gm09_424439 | |
| DS11.46096 | Variant_A | G | G | A | C | |
| DS11.46096 | Variant_B | A | A | G | A | |
| DS11.46096 | Variant | GA | GA | AG | CA | |
+------------+-----------+---------------+-------------+-------------+----------
The problem here is that I can't use pivot in sql server as the number of columns is more than the maximum limit. I get the input table from a sql server query and I need to format it in PHP. After reading a bit, I was able to understand how to do it for simple tables. But I'm not sure how to proceed for the complex table I've. Any help would be much appreciated.
The table is stored in a variable like this and is stored in a retrieved into a variable in PHP.
$tsql = select * from genotypeQA
$params = array( $_REQUEST['query'] );
$getProducts = sqlsrv_query( $conn, $tsql,$params);
I need to format(Pivot) the table in $getProducts in PHP