Hello,
I have a problem with a php and mySQL application. I am designing a HTML table that will list users from a database. They are able to have the amount of tips or total that they have then they have a point margin score that separates the users when they have equal amount of tips.
The problem is that I can sort the user tips in order using php and array functions then I can not seem to work out how I can sort the users that have equal tips to sort their point margin in descending order. I have included in the doublesection.zip file the user table and the php files that display the data and also the php to mySQL connection file that will need to re-configed. I have included a read me file and you have any further question please eMail me at Stephen@pokeycam.net
You can download the doubleselction zip file from http://www.pokeycam.net/dselection.zip
Thanks :-)
Why sort with php functions? Why not just sort in the MySQL query?....ie:
"SELECT tips,userid,pointMargin FROM users ORDER BY tips DESC, pointMargin DESC"
Thanks for that it works, I nearly had it. Thanks for that simple solution, I will be posting more problems, lol.
Sorry just found a problem. If a user has a point margin of -100 and a user has a pointmargin of 2 then I want to work out who is the closet to 0, clearly 2 is but it displays -100 as been on top. Will I have to put it in a negitive number and then when it comes out times it by -1 to change it a + number, how would you convert a negitive to a positive with my script?
An example can be seen at Click Here
if the pointMargin rank is determined by the user who is closest to 0, then simply use the ABS() function of MySQL...ie:
"SELECT tips,userid,pointMargin FROM users ORDER BY tips DESC, ABS(pointMargin) DESC"