- 已关闭。**此问题为not reproducible or was caused by typos。当前不接受答案。
这个问题是由打字错误或无法再重现的问题引起的。虽然类似的问题在这里可能是on-topic,但这个问题的解决方式不太可能帮助未来的读者。
昨天关门了。
Improve this question
类型:错误消息:不能将stdClass类型的对象用作数组$data ['retVal ']= $query-〉result();这是我得到一个错误的地方
$this->db->select('questions.*');
$this->db->from('questions,test_question');
$this->db->where('questions.id=test_question.question_id');
$this->db->where('test_question.test_id = '.$test_id);
$query = $this->db->get();
$data['retVal']=$query->result();
这是我的观点,数据应该显示
<?php
$i=0;
foreach ($retVal as $data )
{
$i++;
echo '<tr>
<td>'.$i.'</td>
<td>'.$data->question.'</td>
<td>'.$data->choice1.'</td>
<td>'.$data->choice2.'</td>
<td>'.$data->choice3.'</td>
<td>'.$data->choice4.'</td>
<td>'.$data->right_choice.'</td>
<td>'.$data->score.'</td>
<td>
<a href="'.base_url('Student/deleteStudent/'.$data->id).'">
<button type="button" class="btn btn-danger btn-sm">Delete</button>
</a>
<a href="'.base_url('Student/loadUpdateStudentView/'.$data->id).'">
<button type="button" class="btn btn-success btn-sm">Update</button>
</a>
</td>
</tr>';
}
?>
1条答案
按热度按时间weylhg0b1#
我在key中使用了$data变量,当我重命名发送到视图的变量时,它会产生问题,它解决了问题