PHP语法错误,意外';endforeach';(T_ENDFOREACH)
我的代码怎么了PHP语法错误,意外';endforeach';(T_ENDFOREACH),php,codeigniter,Php,Codeigniter,我的代码怎么了 <?php foreach($query->result() AS $row);?> <tr> <td><?php echo $row->Qid?> </td> <td><?php echo $row->title?> </td> <td><?php echo $row->da
<?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更改代码:
<?php foreach($query->result() AS $row): ?>
或
您可以使用以下选项:
<?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 } ?>
你应该使用
:
而不是代码>
<?php foreach($query->result() AS $row):?>
--------^
....
<?php endforeach; ?>
--------^
....
您的代码中有两个错误,分别是foreach循环
和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; ?>
///这里您需要使用:而不是;
//在这里你需要把;在结束标记之前?>
//在这里你需要把;在结束标记之前?>
//在这里你需要把;在结束标记之前?>
不要混淆代码>与:
请确保您的模型在每次foreach之前返回数据
或错误
,并确保有任何有效数据要迭代。(if(empty($data))…
)实际上不需要用终止该行使用?>
<?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; ?>