#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2010
    Posts
    15
    Rep Power
    0

    Moving a row up or down in its stack...


    I have a table like this:



    Code:
    			title,iconpath,bannerurl,summary,headerstitle,headers,backurl,forwardurl,torder,thisurl,slidescol
    Education,images/iconeducation.png,images/slideeducationbanner.png,placesummaryhere,theaders,one;two;three,,slides.fastcash.php,1,slides.education.php,1
    "Fast Cash",images/slides.fastcash.png,images/banner.fastcash.png,placesummaryhere,theaders,one;two;three,slides.education.php,slides.creditcards.php,2,slides.fashcash.php,2
    "Credit Cards",images/slides.creditcards.png,images/banner.creditcards.png,placesummaryhere,theaders,one;two;three,slides.creditcards.php,slides.creditcards.php,3,slides.creditcards.php,3
    "Government Aid",images/slides.governmentaid.png,images/banner.governmentaid.png,placesummaryhere,theaders,one;two;three,slides.governmentaid.php,slides.bankrupcy.php,4,slides.bankrupcy.php,4
    I am looking for a way either by way of a MySQL query or through PHP to move an item up through the stack. For instance I may want torder 3 to become 2 and then renumber all the other torders to correspond to three moving to torder 2. The array I am ordering by torder so that my data grid view populates in the right ascending torder.

    I see this could be done in JavaScript, PHP or MySQL but I am thinking if I can do it through MySQL that would be less code...
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,138
    Rep Power
    4274
    have a look at this thread (in another forum)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

IMN logo majestic logo threadwatch logo seochat tools logo