Home  >  Article  >  Web Front-end  >  How to sort data on html pages? (with code)

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

不言
不言Original
2018-08-14 16:57:366107browse

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;

Then use e90145dd58c42c9bf37ce744c0a96dfd 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>

The code uses 99c48a975ea0aa6890fdc4cc57d09a26 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!

Statement:
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