PHP sorting question this post was last edited by u010801782 at 23:32:15
Demo
$ Value) {array_multisort ($ sTime, SORT_ASC, $ value);?>
|
|
$ V) {$ sTime [$ key] = $ v ['stime'];?>
|
|
|
$ V ['stime'] & time () <$ v ['etime']) {echo 'open Zhong';} if (time () <$ v ['stime']) {echo 'not open yet';} if (time ()> $ v ['etime']) {echo 'expired ';}?> |
| Expired |
The final result. how can I move the expired rows to the expired rows in descending order of the time displayed on the front end.
Reply to discussion (solution)
Sort by expiration or not, and then sort by time. order by expiration, time
If only the order is arranged, the expired ones are arranged in reverse chronological order.
$ SQL = 'select * from news order by guoqi desc, time desc
If you want to classify them into different categories, you can perform two cycles. The unexpired list position loops once, and the expired list position loops once, and the fields that expire are determined directly when the content is output in a loop.
If only the order is arranged, the expired ones are arranged in reverse chronological order.
$ SQL = 'select * from news order by guoqi desc, time desc
If you want to classify them into different categories, you can perform two cycles. The unexpired list position loops once, and the expired list position loops once, and the fields that expire are determined directly when the content is output in a loop.
How can we implement the loop output in different categories? Is there an instance?
$ Value) {array_multisort ($ sTime, SORT_ASC, $ value);?>
|
|
$ V) {if (time () <= $ v ['etime']) {$ sTime [$ key] = $ v ['stime'];?>
|
|
|
$ V ['stime'] & time () <$ v ['etime']) {echo 'open Zhong';} if (time () <$ v ['stime']) {echo 'not open yet';}?> |
| Expired |
$ Value) {array_multisort ($ sTime, SORT_ASC, $ value);?>
|
|
$ V) {if (time ()> $ v ['etime']) {$ sTime [$ key] = $ v ['stime'];?>
|
|
|
Expired |
When you determine whether the expiration date has expired in two cycles, the others are displayed.