douqiang7462 2015-04-02 20:05
浏览 171

PHP中的数据透视表

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

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 docker里部署springboot项目,访问不到扬声器
    • ¥15 netty整合springboot之后自动重连失效
    • ¥15 悬赏!微信开发者工具报错,求帮改
    • ¥20 wireshark抓不到vlan
    • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
    • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
    • ¥15 stata安慰剂检验作图但是真实值不出现在图上
    • ¥15 c程序不知道为什么得不到结果
    • ¥15 键盘指令混乱情况下的启动盘系统重装
    • ¥40 复杂的限制性的商函数处理