Code: Select all
ID | TITLE | POSITION | PARENTCode: Select all
1 | TEST | 1 | 2
2 | TEST | 2 | 2
3 | TEST | 3 | 2Code: Select all
1 | TEST | 1 | 2
3 | TEST | 3 | 2I tried playing, that is:
Code: Select all
$result = $mysql->query("SET @counter = 0;");
$result = $mysql->query("SELECT `static_id`,
IF (`static_position`=@counter, @counter:=@counter+1, @counter:=@counter+1) as `static_new_position`
FROM `gcms_static` WHERE `static_parent_id`='$parent_id' ORDER BY `static_new_position`, `static_id`") or die(mysql_error());