我的代码有什么问题
<?php foreach($query->result() AS $row);?>
<tr>
<td><?php echo $row->Qid?> </td>
<td><?php echo $row->title?> </td>
<td><?php echo $row->date?> </td>
</tr>
<?php endforeach; ?>
错误消息:语法错误,意外的'endforeach'(T_ENDFOREACH) 使用Codeigniter
答案 0 :(得分:16)
更改您的代码:
<?php foreach($query->result() AS $row): ?>
change ; to :
OR
你可以用这个:
<?php foreach($query->result() AS $row){ ?>
<tr>
<td><?php echo $row->Qid?> </td>
<td><?php echo $row->title?> </td>
<td><?php echo $row->date?> </td>
</tr>
<?php } ?>
答案 1 :(得分:7)
您应该使用:
代替;
<?php foreach($query->result() AS $row):?>
--------^
....
<?php endforeach; ?>
答案 2 :(得分:3)
您的代码中有两个错误:foreach loop
和echo
<?php foreach($query->result() AS $row):?>///here you need to use : instead of ;
<tr>
<td><?php echo $row->Qid; ?> </td> // here you need to put ; before closing tag ?>
<td><?php echo $row->title; ?> </td>// here you need to put ; before closing tag ?>
<td><?php echo $row->date; ?> </td>// here you need to put ; before closing tag ?>
</tr>
<?php endforeach; ?>