Professional Web Applications Themes

Order in the row! - MySQL

Hey guys, I'm new here and I hope its OK if I tap a lil into your knowledge base. I have a table ID|Name|Job the ID is an int that auto increases and should stay the same for history record. Now I want to put order to the table. Not by ID, not by name, not by job. so I want to add a order collumn, but I'm not sure what values it should have. I want to list the names and decide to move them up or down in order. e.g. ID:1-Steve-Farmer (move up in order button)(move down in ...

  1. #1

    Default Order in the row!

    Hey guys,
    I'm new here and I hope its OK if I tap a lil into your knowledge
    base.

    I have a table

    ID|Name|Job


    the ID is an int that auto increases and should stay the same for
    history record.
    Now I want to put order to the table.
    Not by ID, not by name, not by job.
    so I want to add a order collumn, but I'm not sure what values it
    should have.
    I want to list the names and decide to move them up or down in order.
    e.g.

    ID:1-Steve-Farmer (move up in order button)(move down in order button)
    ID:2-Jim-Hunter (move up in order button)(move down in order
    button)
    ID:3-Al-Baker (move up in order button)(move down in order
    button)

    then if i click the (move up in order button) from Jim the list would
    look like this

    ID:2-Jim-Hunter (move up in order button)(move down in order
    button)
    ID:1-Steve-Farmer (move up in order button)(move down in order button)
    ID:3-Al-Baker (move up in order button)(move down in order
    button)

    i hope you get the gist of what I want.
    so what values should i use and how should they change to get the
    effect I want? the list will probably be huge and its not really about
    jobs and names but i just used this as an example.
    Thanks for any ideas
    Mawk

    Mohawk Guest

  2. #2

    Default Re: Order in the row!

    On 15 May 2007 01:15:28 -0700, Mohawk Mawk <com>
    wrote:
     

    You might need another field : parent, same type as your ID, and being
    unique.
    You also need a top-row with ID 0 or something of the kind you will
    never change.

    ID:0-EMPTY-EMPTY Parent:NULL
    ID:1-Steve-Farmer Parent : 0
    ID:2-Jim-Hunter Parent 1
    ID:3-Al-Baker Parent 2

    Then when you hit on Jim to put it up, you update Jim and Steve, to
    have Jim having EMPTY as Parent, and Steve having Jim.

    Then you SELECT everything again, and you always ORDER BY Parent.
    subtenante Guest

  3. #3

    Default Re: Order in the row!

    On May 15, 10:11 am, subtenante <com> wrote: 







    >
    > You might need another field : parent, same type as your ID, and being
    > unique.
    > You also need a top-row with ID 0 or something of the kind you will
    > never change.
    >
    > ID:0-EMPTY-EMPTY Parent:NULL
    > ID:1-Steve-Farmer Parent : 0
    > ID:2-Jim-Hunter Parent 1
    > ID:3-Al-Baker Parent 2
    >
    > Then when you hit on Jim to put it up, you update Jim and Steve, to
    > have Jim having EMPTY as Parent, and Steve having Jim.
    >
    > Then you SELECT everything again, and you always ORDER BY Parent.[/ref]

    http://www.phpriot.com/d/articles/client-side/sortable-lists-with-php-and-ajax/index.html

    strawberry Guest

Similar Threads

  1. Tab Order always greyed out, need to redefine order but can't
    By Dominic_De_Lello@adobeforums.com in forum Adobe Acrobat Macintosh
    Replies: 5
    Last Post: July 14th, 05:06 AM
  2. Replies: 2
    Last Post: January 18th, 02:07 PM
  3. Updating records in order (into an order)
    By A Ratcliffe in forum ASP Database
    Replies: 7
    Last Post: October 24th, 06:19 PM
  4. Replies: 3
    Last Post: April 18th, 12:52 PM
  5. Replies: 0
    Last Post: April 15th, 01:22 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139