PHP Sort Questions

Source: Internet
Author: User
This post was last edited by u010801782 on 2013-07-30 23:32:15

 
 
  
 <title>Demo</title>
 
 
  $value) {Array_multisort ($sTime, SORT_ASC, $value);? >
      
  
   $v) {$sTime [$key] = $v [' stime '];? >
   
$v [' stime '] && time () < $v [' etime ']) {echo ' open ';} if (Time () < $v [' stime ']) {echo ' temporarily not open ';} if (Time () > $v [' etime ']) {echo ' expired ';} ?>
Has expired




The final effect, ask how the front-end display when the time-size descending and already expired line moved to the expired under.


Reply to discussion (solution)

Sort by expiration first, then by time, and order by expires

If the order is only sequential, the expired next side does not expire at the top of each of the reverse chronological order

$sql = ' SELECT * ' from News order by Guoqi Desc,time desc

If you need to categorize it for two cycles, the list position that has not expired is cycled once, the expired list position is cycled once, and the field that is determined to expire directly when the content is looped out

If the order is only sequential, the expired next side does not expire at the top of each of the reverse chronological order

$sql = ' SELECT * ' from News order by Guoqi Desc,time desc

If you need to categorize it for two cycles, the list position that has not expired is cycled once, the expired list position is cycled once, and the field that is determined to expire directly when the content is looped out

Need to classify the loop output, how can I do? Do you have an example?

 
  $value) {Array_multisort ($sTime, SORT_ASC, $value);? >
      
   $V) {if (Time () <= $v [' etime ']) {$sTime [$key] = $v [' stime ']; ?>
   
   $value) {Array_multisort ($sTime, SORT_ASC, $value);? >
       
   $V) {if (Time () > $v [' etime ']) {$sTime [$key] = $v [' stime ']; ?>
   
$v [' stime '] && time () < $v [' etime ']) {echo ' open ';} if (Time () < $v [' stime ']) {echo ' is temporarily open ';}? >
Has expired
Has expired


Two cycles in the loop to determine whether the expiration has expired the bottom display other top display
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.