[英]How to display a unordered list with unique bullets based on condition?
I am generating a list from sql server, filtering it based on new and old records and displaying them in their respective categories on the webpage. 我正在从sql server生成一个列表,根据新旧记录对其进行过滤,并在网页上的相应类别中显示它们。 I want to show unique list bullets for old and new records.
我想显示新旧记录的唯一列表项目符号。 What Im currently getting is a mashup of every record from each category on top of eachother.
我目前正在获得的是将每个类别中的每个记录彼此融合在一起。 The icons for the list items are coming from some twitter bootstrap css, using glyphicons.
列表项的图标使用glyphicons来自某些twitter引导CSS。 The new records also have a popover that displays on hover.
新记录还具有一个悬停时显示的弹出窗口。 The list-generating code
列表生成代码
foreach($resultArray as $category_name => $items)
{
echo '<h3>'. $category_name.'</h3><ul>';
foreach($items as $itemid => $itemDetails)
{
?>
<li class="<?php if(strtotime($itemDetails['posted']) > (strtotime('-30 days'))){echo 'icon-star';} else {echo '';} ?>" data-content="This item is new on Corkboard. Check it out!" data-original-title="New Item">
<?php
echo '<a href="newGenView.php?id='.$itemid.'">'.$itemDetails['name'].' - '.$itemDetails['description'].'</a>';
?>
</li>
<?php
}//foreach
echo '</ul>';
}//foreach
?>
And, I have these script tags: 而且,我有以下脚本标签:
<script type="text/javascript" src="assets/js/bootstrap-popover.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(this).popover(options);
});
</script>
Any ideas or other ways to do this solution? 有什么想法或其他方式可以实现此解决方案吗?
data-content
attributes to the new <li>
. data-content
属性添加到新的 <li>
。 <li>
s and remove parameter options
, if you don't initialize it. <li>
并删除参数options
。 <i>
like in the bootstrap description . <i>
中。 The final html could be: 最终的html可能是:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<style type='text/css'>
ul { list-style: none inside none; margin: 0; }
li { display: inline; }
</style>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script type='text/javascript' src="http://twitter.github.com/bootstrap/assets/js/bootstrap-tooltip.js"></script>
<script type='text/javascript' src="http://twitter.github.com/bootstrap/assets/js/bootstrap-popover.js"></script>
<script type='text/javascript'>
$(document).ready(function() { $('li').popover(); });
</script>
</head>
<body>
<h3>category_name</h3>
<ul>
<li>
<i class="icon-minus"></i>
<a href="newGenView.php?id=1">name1 - description1</a><br />
</li>
<li data-content="This item is new on Corkboard. Check it out!" data-original-title="New Item">
<i class="icon-star"></i>
<a href="newGenView.php?id=2">name2 - description2</a><br />
</li>
</ul>
</body>
</html>
Also see this example . 另请参见此示例 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.