The situation I have is a page with contact names which echos the 5 most frequently visited contacts of the current user. and I order them like this:
$name_a=mysql_query(SELECT * FROM contacts WHERE email='$semail' ORDER BY frequency
DESC);
$name_b=mysql_query(SELECT * FROM contacts WHERE email='$semail' ORDER BY frequency
DESC OFFSET1);
and when the member clicks a submit button associated with this name it adds 1 to the ‘frequency’ column of that user. like this:
UPDATE contacts SET frequency = frequency + 1 WHERE email='$semail' AND
contact_a='$a[contact_a]'
The problem comes when two members have the same frequency value, because when one of these names is clicked it adds 1 and changes the order so then the other information appears after the page refreshes. for example if both ‘tom’ and ‘bob’ have a frequency value of 10
tom is echoed first(because his name appears first in the database) then bob, like this:
if ($name_a = mysql_fetch_assoc($name_a)) {echo $name_a['firstname'];} // eg. tom
if ($name_b = mysql_fetch_assoc($name_b)) {echo $name_b['firstname'];} // eg. bob
then if someone clicks the button for bob, his frequency value becomes 11 and when the page has refreshed he becomes $name_a and additional information which comes from clicking the submit button will be for tom. hope I have explained this OK. Thanks
...ORDER BY frequency, name, so that within any given frequency, names will be alphabetical, instead of whatever their natural sort order is?