<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> 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似乎自动增加它的默认值)
不是- Lorem Ipsum postla 28.02.2013
- 2013年2月28日
虽然Chrome显示它应该(1和2),但Opera和Internet Explorer显示每个条目1。谢谢!
拿走H3
标签,你就没事了!
你不应该用UL
或OL
以外的任何东西来包装你的LI
标签。
问题是在您的<h3>
标签在<li>
之前打开,列表的模式是
<ol>
<li>...</li>
</ol>
把你的html改成
...
<ol>
<li><h3>...</h3></li>
</ol>
...
这不是因为<ol> tag
,试试ul
吧。-使用<?php foreach ($articles as $i = >$article)
显示<?= $i ?>