Rishi2686 Rishi2686 - 3 months ago 30
PHP Question

Issues in sorting image-wise

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?


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.