How to sort data on html pages? (with code)

不言
Release: 2018-08-14 16:57:36
Original
6088 people have browsed it

The content of this article is about how to sort data on html pages? (Attached is the code), which has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

I used this little trick when ranking results a few days ago. You can implement data sorting function by directly using el expression in html code. This is my first time blogging, so please give me some advice. .

To rank the results, you must first take out the data in positive order:

select * from table where 1 = 1 order by score desc;
Copy after login

Then use <c:foreach> to traverse the data and add EL expression at the same time Formula to display the ranking:

<c:set var="number" value="1"></c:set>
<c:foreach item="${array }" var="data">
    <span>名次:</span>${number }
    <span>成绩:</span>${data.score }
    <c:set var="number" value="${number+1 }"></c:set>
</c:foreach>
Copy after login

The code uses <c:set> to define and operate the data number. If it is paging data, you only need to ${number } can be replaced with ${number (currentPage-1) }. Where currentPage is the page number of the current page.

Related recommendations:

How to implement message board style in html? (Code example)

#How to center-align text in HTML? (Code example)

Code for combining html and css to realize mobile web page adaptation

The above is the detailed content of How to sort data on html pages? (with code). For more information, please follow other related articles on the PHP Chinese website!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!