Posted by Jon on 01/20/06 21:27
I don't understand the query here - If I'm selecting WHERE
SortOrder=(SortOrder+1) - I don't know what sortOrder is. Do I have to pass
the current sortOrder ID within the query string?
"Adam Plocher" <aplocher@gmail.com> wrote in message
news:1137779135.046241.4690@g14g2000cwa.googlegroups.com...
> Does this fix the problem? It will attempt to find the "replaceID"
> automatically. You shouldn't need to shift every item, just the item
> before or after the item you want to move.
>
> function MoveUp($id)
> {
> $query = "SELECT ID FROM table WHERE SortOrder=(SortOrder+1)";
> $ret = mysql_query($query);
> if (mysql_num_rows($ret) == 1)
> {
> // if 0 rows returned, don't change the sortorder
> list($replaceID) = mysql_fetch_row($ret);
>
> $query = "UPDATE table SET SortOrder=(SortOrder-1) WHERE ID=$id"
> mysql_query($query);
>
> $query = "UPDATE table SET SortOrder=(SortOrder+1) WHERE ID=$replaceID"
> mysql_query($query);
> }
> }
>
Navigation:
[Reply to this message]
|