views:

23

answers:

2

Hi there,

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?

Thank you in advance.

A: 

You need to change your sql query - something like:

SELECT * FROM `users` ORDER BY `created` DESC
adam
+1  A: 

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.

Andy
i just edit above question to get full idea.
Rishi2686