Home > Backend Development > PHP Tutorial > 如何根据smarty模板中定义的数字获取相应的新闻条数

如何根据smarty模板中定义的数字获取相应的新闻条数

WBOY
Release: 2016-06-13 12:42:53
Original
780 people have browsed it

怎么根据smarty模板中定义的数字获取相应的新闻条数?
刚接触smarty模板,想在模板中控制显示的新闻条数,如下显示5条新闻

<ul><br />
{section name=news loop=$arr max=5}<br />
	<li>{$arr[news].title}</li><br />
{/section}<br />
</ul><br />
Copy after login


请问在php程序中怎么根据模板中的条数来读取相应的记录数?怎么获取模板中设置的条数?
从而实现下面的SQL:
SELECT id, title, wdate FROM news ORDER BY id DESC LIMIT 0, 5
Copy after login

而不是:
SELECT id, title, wdate FROM news ORDER BY id DESC
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template