数据库查查出的数据怎么显示在日历中
我用smarty模板写的,日历按月显示
从数据库查出当月数据的日期(日),要显示在这个日历上。
现在的问题是我写了两个循环
<!--
Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/
-->
//当月天数循环(比如现在是6月就是30天)
{section name=d loop=$dayofmonth}
//数据库查出的数据记录循环
{section name=e loop=$events}
//如果数据库查出的记录的日期(天day)==循环的当月天数执行如下显示
{if ($events[e].event_starttime|date_format:"%d") == ($smarty.section.d.index+1)}
<td class="date_pic"><span class="date_number">{$events[e].event_starttime|date_format:"%d"}</span>
<div class="date_list">
<ul>
<li>
<a href="./events.php?eid={$events[e].eid}" target="_blank">{$events[e].event_name}</a>
</li>
</ul>
</div>
<a href="./events.php?eid={$events[e].eid}" target="_blank">
<img style="max-width:90%" style="max-width:90%" src="./Uploads/{$events[e].event_poster}" alt=" 数据库查查出的数据如何显示在日历中 " ><script src="https://www.php.cn/hezuo/f220a8ffcae8732bbc8e3d8f7f36834b.js"></script>
</a>
</td>
{/if}
{/section}
//[color=#FF0000]问题现在就在这里,下面的条件3,4,6,11,12就是我从数据库查出数据的天(day),[color=#00FF00]为了不重复输出[/color],我写了下面的if判断,问题是我的月份是变化的,所以数据库查找出来的数据也是变化的,所以不可能每个月都是3,4,6,11,12。要根据数据库的数据改变,所以我的想法是下面这个if怎么改写?smarty模板里的if条件能循环?或者有其他思路?各位大虾帮忙,想了一天了[/color]
{if (($smarty.section.d.index+1) != 3)&&
(($smarty.section.d.index+1) != 4)&&
(($smarty.section.d.index+1) != 6)&&
(($smarty.section.d.index+1) != 11)&&
(($smarty.section.d.index+1) != 12)}
<td class="" style="cursor:auto;"><span class="date_number">{$smarty.section.d.index+1}</span> </td>
{/if}
//7天换一行
{if ($smarty.section.d.index+$day1ofweek+1)%7==0}
</tr>
{/if}
{/section}
id date data 1 2012-06-01 none 2 2012-06-02 good 3 2012-07-05 true <div class="clear"></div>
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号