play_ Posted October 30, 2008 Share Posted October 30, 2008 I have a list of images the user can re-order using javascript(sortables) When the user re-arrange the images, moving their position around, it returns me the order of the images. now in the database, my images table looks(in short) like this: | name | size | order | +------+-----+------+ | a.jpg | 12 | 1 | | b.jpg | 12 | 2 | | c.jpg | 12 | 3 | After images are rearranged, it sends their order to a PHP script( i send it as ints). I put them into an array, so it looks like this:( say ajax sends the new order as( 2, 3 , 1) $order[0] = 2 $order[1] = 3 $order[2] = 1. What i would like to do, is now have picture 'a.jpg' `order` column be 2, 'b'.jpg' `order` column be 3 'c.jpg' `order` column be 1 in the database How would i do such update? Would i have to pass the name(or id) of the image through ajax as well, so i could(in a loop) do: update images set `order` = {$order[0]} where ID = $id or is there a simpler way? Link to comment https://forums.phpfreaks.com/topic/130767-solved-how-to-do-this-kind-of-update/ Share on other sites More sharing options...
trq Posted October 30, 2008 Share Posted October 30, 2008 Would i have to pass the name(or id) of the image through ajax as well Indeed you would. Link to comment https://forums.phpfreaks.com/topic/130767-solved-how-to-do-this-kind-of-update/#findComment-678683 Share on other sites More sharing options...
play_ Posted October 30, 2008 Author Share Posted October 30, 2008 Thank you. Link to comment https://forums.phpfreaks.com/topic/130767-solved-how-to-do-this-kind-of-update/#findComment-678697 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.