繁体   English   中英

PHP语法错误,意外的'endforeach'(T_ENDFOREACH)

[英]PHP syntax error, unexpected 'endforeach' (T_ENDFOREACH)

我的代码出了什么问题

 <?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;  ?>

错误消息: 语法错误,使用Codeigniter的意外'endforeach'(T_ENDFOREACH)

改变你的代码:

 <?php foreach($query->result() AS $row): ?>
 change ; to : 

要么

你可以用这个:

<?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 loopecho

<?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;  ?>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM