i m trying to do a manual ordering (sorting) of items in my table not quite good at it and can't seem to figure it out so would like some help. basically there's a column called 'sort' that stores integers,
pid | pid | sort
----------+--------------+-------
Alvin | 1001 | 1
Tom | 1002 | 2
Jerry | 1003 | 3
i need help with the codes to repositioning the rows... i.e. I m using php to parse variables via URL sort.php?do=up&pid=1002&sort=2
Clicking "UP" on top would result in Tom becoming 1, and Alvin drops to 2
Then the desired outcome would be the sorting will now change to
pid | pid | sort
----------+--------------+-------
Alvin | 1001 | 2
Tom | 1002 | 1
Jerry | 1003 | 3
Would also like to know the opposite of this which is a "DOWN" reorder
Much appreciated!
ORDER BY column ASCorORDER BY column DESCthat will give you an UP-DOWN sorting order. Then just use the query inside a function using anissetconditional statement.