我从数据库中获取表数据并将其显示在db中,但是出现问题。 管理员添加测验标记时,动态创建数据库中的测验列。 现在,当我无法显示针对测验标题的每一列的数据时。
我可以使用foreach在标记中显示测验编号,但是我无法针对该测验显示标记。 请引导我。
var x = new String(variabledatahere)
//Manage Grades_model.php
public function GetAllQuizMarks()
{
$this->db->select('*');
$this->db->from('quizmarks');
$query = $this->db->get();
return $query->result();
}
//ManageGrades.php
//this is controller
public function GetAllQuizMarks()
{
$data['markslist']=$this->ManageGrades_model->GetAllQuizMarks();
$this->load->view('Manage/GetAllQuizMarks',$data);
}
答案 0 :(得分:0)
这可能对您有帮助。
//This is view file
<div class="panel-body">
<div id="dataTables-example_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
<div class="row">
<div class="col-sm-12">
<table width="100%" class="table table-striped table-bordered table-hover dataTable no-footer dtr-inline" id="dataTables-example" role="grid" aria-describedby="dataTables-example_info" style="width: 100%;">
<thead>
<tr role="row">
<th>Sr #</th>
<th>Name</th>
<th>Roll No.</th>
<th>Quiz marks</th>
</tr>
</thead>
<tbody>
<?php
$Counter1=1;
foreach($markslist as $designation)
{
?>
<tr class="gradeA odd" role="row">
<td class="sorting_1"><?php echo $Counter1++;?></td>
<td class="sorting_1"><?php echo $designation->name;?></td>
<td class="sorting_1"><?php echo $designation->rollno;?></td>
<td class="sorting_1"><?php echo $designation->marks; //use you column name for mark mere?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>