我想制作一个包含用户所有项目的列表,按用户划分..
<div id="news-block">
<h3 id="news-title">USER NAME</h3>
<ul id="news-content">
<li>ITEM 1</li>
<li>ITEM 2</li>
<li>ITEM 3</li>
</ul>
我有这个 php,我的问题是标题:
<div id="news-block">
<?php
echo "<ul id='news-content'>";
$username=null;
foreach ($programas as $programa) {
if ($programa->username!= $username) {
$nombre = $programa->username;
echo "<h3 id='news-title'>".$programa->username."</h3>";
}
echo "<li>".$programa->titulo."</li>";
}
echo "</ul>";
?>
显然这段代码是错误的,因为我不能重复用户的名字..