2014-10-31 77 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); 
相关问题