Reputation: 127
I have a table in which there are fields like user name, name, age, activity. In this if new user is added then an image is shown beside that user name.
Until now sorting was done by activity by default, but I want all the newly added users to be shown first in the table by default, how can i sort in this case?
Any hint?
Upvotes: 0
Views: 64
Reputation: 2774
Without knowing, well, anything, about how you're implementing this, it's a bit tricky.
If the data from the table is coming from a database and you're already sorting based on some activity field, then your query just needs to sort on an additional field: instead of ORDER BY activity
you might have ORDER BY isnew, activity
or ORDER BY image, activity
.
Alternatively, if the data is just in a PHP data structure, then you could just do a two stage render of your table - iterate through and write out rows with an image, then again for the ones without.
Upvotes: 1
Reputation: 28795
You need to change your sql query - something like:
SELECT * FROM `users` ORDER BY `created` DESC
Upvotes: 0