Php makes a ranking by time, and php makes a ranking by time. in the figure, the ranking is in reverse chronological order, and the queuing fields need to be in chronological order.
Correct queuing order and serial number are reversed by 5.4.3.2.1
Reply to discussion (solution)
I'm a master of magic!
Isn't order by time enough?
If the data can be written in reverse order by id
select * from table order by id desc;
Isn't order by time enough?
This method is acceptable, but the previous serial number is based on desc, while the queuing behind is based on asc, so it is difficult. The boss is too picky.
Your queue column does not have data
Order by field
Desc or asc
Ascending desc
Asc in descending order
Your queue column does not have data
Well, there is no data. the serial number column is $ key, which is sorted in descending order. Sort columns in ascending order. SQL statements can only be sorted once. So now we are struggling. The initial plan is to add a field, and then write a loop statement to write the ranking to this field. The id is recycled continuously, so that each data entry has the value of the sorting field. However, it does not loop by ID
So what is the basis of your ranking?
So what is the basis of your ranking?
The ranking is based on the ascending time order, while the serial number is based on the descending time order. So there are two conflicts.
Your serial number is generated by the php code during output.
Then your ranking is the total number-serial number
Ranking 1 52 43 34 2 5 1
Your serial number is generated by the php code during output.
Then your ranking is the total number-serial number
Ranking 1 52 43 34 2 5 1
That's right. I just want this effect. How did it come out? I don't understand.
Isn't it difficult to get the total number of records of the query results?
So
Echo 'sequence number '. $ I. 'ranking'. ($ count-$ I );
$ I ++;
No?