PHP生成的有序列表不起作用


ordered list generated by php doesn't work

<ol>
    <?php foreach ($articles as $article) { //start of the loop
        ?> //interruption to allow html to be passed rather than echoed
           <h3><li>
           <a href="article.php?id=<?php echo $article['article_id']; ?>"><?php echo $article['article_title']; ?></a>
           <small> &nbsp; postat la     
               <?php 
                   echo date('d.m.Y', $article['article_timestamp']);
               ?>
           </small>
          </li></h3>
         <?php //'starting' php again to close the loop
    } ?> //closing loop and coming back to html to allow closing the </ol>
</ol>

但是我仍然不知道为什么我没有从数据库中得到元素。

我得到的是:

"1"。Lorem Ipsum post la 28.02.2013

"1"。一些文本发布于2013年2月28日(我把他们周围的引号,因为stackoverflow似乎自动增加它的默认值)

不是

  1. Lorem Ipsum postla 28.02.2013
  2. 2013年2月28日

虽然Chrome显示它应该(1和2),但Opera和Internet Explorer显示每个条目1。谢谢!

拿走H3标签,你就没事了!

你不应该用ULOL以外的任何东西来包装你的LI标签。

问题是在您的<h3>标签在<li>之前打开,列表的模式是

<ol>
  <li>...</li>
</ol>
把你的html改成
...
<ol>
    <li><h3>...</h3></li>
</ol>
...

这不是因为<ol> tag,试试ul吧。-使用<?php foreach ($articles as $i = >$article)显示<?= $i ?>