2014-10-31 72 views
0

如何顯示來自的數據moodle databsehtml表格如何在html表格中顯示來自moodle databse的數據

我試了一下..

$all_response = get_response_details($refid); 
    if($all_response){ 
    $all_response = array_values($all_response); 
    $responseCount = count($all_response); 
    //table 
    $table = new html_table(); 
    $table->head = array('Name ','email', 'status', 'Grade'); 
    for($k=0;$k<$responseCount;$k++) 
    { 
     $stud_details = get_student_detail($all_response[$k]->student_id);//student details 
     $stud_details = array_values($stud_details); 
     $quest_details = get_quetion_by_id($all_response[$k]->qn_id, $all_response[$k]->ref_id); 

     $table->data = array(array($stud_details[0]->firstname, $stud_details[0]->email, $all_response[$k]->sub_status, $grade_date)); 

    echo html_writer::table($table); 
    } 

但問題是單獨的表顯示每個數據。那就是如果有3條記錄在那裏顯示三張表。

我把echo html_writer::table($table);放在for循環之外,那麼只應該顯示一行。

我必須在單個表中顯示所有記錄。任何幫助是明顯的....

我使用Moodle的2.7

回答

0

你能嘗試

// Add the [] to data and just a single array. 
    $table->data[] = array($stud_details[0]->firstname, $stud_details[0]->email, $all_response[$k]->sub_status, $grade_date); 

} 
// Outside the loop. 
echo html_writer::table($table); 
相關問題