2016-06-20 19 views
0

我已經使用jQuery的數據表,如何在數據表中設置垂直數組?

HTML代碼

<table id="result_table" class="display table table-bordered" cellspacing="0" width="100%"> 
       <thead> 
        <tr> 
         <th>#</th> 
         <th>Username</th> 
         <th>Activation Status</th> 
         <th>Recent Login</th> 
         <th>Total No. of login</th> 
         <th>Avg No. of login/day</th> 
         <th>Total No. of Exports</th> 
         <th>Total No. of access</th> 
        </tr> 
       </thead> 
       <tfoot> 
        <tr> 
         <th>#</th> 
         <th>Username</th> 
         <th>Activation Status</th> 
         <th>Recent Login</th> 
         <th>Total No. of login</th> 
         <th>Avg No. of login/day</th> 
         <th>Total No. of Exports</th> 
         <th>Total No. of access</th> 
        </tr> 
       </tfoot> 
      </table> 

,我必須加載AJAX調用表中的數據在JSON數據類型在這裏我的PHP代碼

while($row = mysql_fetch_array($run_query)){ 
    $name = $row['first_name']; 
    $name_string = "<a edit_id='name_".trim($name)."' href='#' onClick=\"click_today('{$name}');\" data-toggle='modal' data-target='#myModal'>{$name}</a>"; 

    //onClick=\"click_today('{$name}');\" 
    $result_array[] = array($row['id'], $name_string, $row['last_name'], $row['job_title'], $row['salary'],"-","-","-"); 
} 
echo json_encode($result_array); 

acutually我的結果是(樣本輸出) enter image description here

但我想要下面的圖像數據輸出表 enter image description here

我不知道如何實現在jQuery的數據表垂直頭,我總是利用水平THEAD但現在我需要垂直頭,因爲需要請份額烏爾建議或解決方案

回答

0

是可能的使這種輸出從服務器端[php]只有然後 分配數據表。我也面臨這個問題,但我讓服務器端 和另一種方式也在那裏你改變你的預期格式使用樞軸表 使用數據庫