Ordering models in a list then saving to db

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Matt Fletcher

    Ordering models in a list then saving to db

    Hi guys,

    I am trying to allow the models in a mysql database to be ordered by the
    site owner.

    I was thinking along the lines of a <SELECT> list containing the model names
    and Up and Down buttons to move the models up and down the list.

    I am unable to come up with a solution for getting the order from the list
    however.

    Any suggestions?

    Thanks for your time,

    Matt


  • Tim Van Wassenhove

    #2
    Re: Ordering models in a list then saving to db

    In article <c7qpgd$bg$1@he rcules.btintern et.com>, Matt Fletcher wrote:[color=blue]
    > Hi guys,
    >
    > I am trying to allow the models in a mysql database to be ordered by the
    > site owner.[/color]

    So you should lookup the "ORDER BY" part in a SQL query.
    [color=blue]
    > I was thinking along the lines of a <SELECT> list containing the model names
    > and Up and Down buttons to move the models up and down the list.
    >
    > I am unable to come up with a solution for getting the order from the list
    > however.[/color]

    You could add a column to your model table that contains the
    ordernumber. And then use ORDER BY order in your query.


    --

    Comment

    • Matt Fletcher

      #3
      Re: Ordering models in a list then saving to db

      Yeah I was thinking the same but how can i get the order from the list
      Thanks


      "Tim Van Wassenhove" <euki@pi.be> wrote in message
      news:2gcq1iF1av m2U2@uni-berlin.de...[color=blue]
      > In article <c7qpgd$bg$1@he rcules.btintern et.com>, Matt Fletcher wrote:[color=green]
      > > Hi guys,
      > >
      > > I am trying to allow the models in a mysql database to be ordered by the
      > > site owner.[/color]
      >
      > So you should lookup the "ORDER BY" part in a SQL query.
      >[color=green]
      > > I was thinking along the lines of a <SELECT> list containing the model[/color][/color]
      names[color=blue][color=green]
      > > and Up and Down buttons to move the models up and down the list.
      > >
      > > I am unable to come up with a solution for getting the order from the[/color][/color]
      list[color=blue][color=green]
      > > however.[/color]
      >
      > You could add a column to your model table that contains the
      > ordernumber. And then use ORDER BY order in your query.
      >
      >
      > --
      > http://home.mysth.be/~timvw[/color]


      Comment

      • Matt Fletcher

        #4
        Re: Ordering models in a list then saving to db

        Yeah I was thinking the same but how can i get the order from the list
        Thanks

        "Tim Van Wassenhove" <euki@pi.be> wrote in message
        news:2gcq1iF1av m2U2@uni-berlin.de...[color=blue]
        > In article <c7qpgd$bg$1@he rcules.btintern et.com>, Matt Fletcher wrote:[color=green]
        > > Hi guys,
        > >
        > > I am trying to allow the models in a mysql database to be ordered by the
        > > site owner.[/color]
        >
        > So you should lookup the "ORDER BY" part in a SQL query.
        >[color=green]
        > > I was thinking along the lines of a <SELECT> list containing the model[/color][/color]
        names[color=blue][color=green]
        > > and Up and Down buttons to move the models up and down the list.
        > >
        > > I am unable to come up with a solution for getting the order from the[/color][/color]
        list[color=blue][color=green]
        > > however.[/color]
        >
        > You could add a column to your model table that contains the
        > ordernumber. And then use ORDER BY order in your query.
        >
        >
        > --
        > http://home.mysth.be/~timvw[/color]


        Comment

        • Matt Fletcher

          #5
          Re: Ordering models in a list then saving to db

          Yeah I was thinking the same but how can i get the order from the list
          Thanks


          "Tim Van Wassenhove" <euki@pi.be> wrote in message
          news:2gcq1iF1av m2U2@uni-berlin.de...[color=blue]
          > In article <c7qpgd$bg$1@he rcules.btintern et.com>, Matt Fletcher wrote:[color=green]
          > > Hi guys,
          > >
          > > I am trying to allow the models in a mysql database to be ordered by the
          > > site owner.[/color]
          >
          > So you should lookup the "ORDER BY" part in a SQL query.
          >[color=green]
          > > I was thinking along the lines of a <SELECT> list containing the model[/color][/color]
          names[color=blue][color=green]
          > > and Up and Down buttons to move the models up and down the list.
          > >
          > > I am unable to come up with a solution for getting the order from the[/color][/color]
          list[color=blue][color=green]
          > > however.[/color]
          >
          > You could add a column to your model table that contains the
          > ordernumber. And then use ORDER BY order in your query.
          >
          >
          > --
          > http://home.mysth.be/~timvw[/color]


          Comment

          • Kevin Collins

            #6
            Re: Ordering models in a list then saving to db

            In article <2gcq1iF1avm2U2 @uni-berlin.de>, Tim Van Wassenhove wrote:[color=blue]
            > In article <c7qpgd$bg$1@he rcules.btintern et.com>, Matt Fletcher wrote:[color=green]
            >> Hi guys,
            >>
            >> I am trying to allow the models in a mysql database to be ordered by the
            >> site owner.[/color]
            >
            > So you should lookup the "ORDER BY" part in a SQL query.
            >[color=green]
            >> I was thinking along the lines of a <SELECT> list containing the model names
            >> and Up and Down buttons to move the models up and down the list.
            >>
            >> I am unable to come up with a solution for getting the order from the list
            >> however.[/color]
            >
            > You could add a column to your model table that contains the
            > ordernumber. And then use ORDER BY order in your query.[/color]
            ^^^^^

            Actually, I doubt very seriously you could do that since 'order' is reserved
            word in mySQL and you would not be allowed to create a table with that column
            name...

            Kevin

            Comment

            • Pedro Graca

              #7
              Re: Ordering models in a list then saving to db

              Kevin Collins wrote:[color=blue]
              > In article <2gcq1iF1avm2U2 @uni-berlin.de>, Tim Van Wassenhove wrote:[/color]
              [color=blue][color=green]
              >> You could add a column to your model table that contains the
              >> ordernumber. And then use ORDER BY order in your query.[/color][/color]
              [color=blue]
              > Actually, I doubt very seriously you could do that since 'order' is reserved
              > word in mySQL and you would not be allowed to create a table with that column
              > name...[/color]



              SCNR


              mysql> CREATE TABLE impossible (
              -> id int primary key auto_increment,
              -> `order` int
              -> );
              Query OK, 0 rows affected (0.01 sec)

              mysql> INSERT INTO impossible values(NULL, 5), (NULL, 4), (NULL, 8), (NULL, 1);
              Query OK, 4 rows affected (0.00 sec)
              Records: 4 Duplicates: 0 Warnings: 0

              mysql> SELECT * FROM impossible ORDER BY `order`;
              +----+-------+
              | id | order |
              +----+-------+
              | 4 | 1 |
              | 2 | 4 |
              | 1 | 5 |
              | 3 | 8 |
              +----+-------+
              4 rows in set (0.01 sec)

              mysql>

              --
              USENET would be a better place if everybody read: : mail address :
              http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
              http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
              http://www.expita.com/nomime.html : to 10K bytes :

              Comment

              • Tim Van Wassenhove

                #8
                Re: Ordering models in a list then saving to db

                In article <slrnca5d7q.1gi .spamtotrash@do om.unix-guy.com>, Kevin Collins wrote:[color=blue]
                > In article <2gcq1iF1avm2U2 @uni-berlin.de>, Tim Van Wassenhove wrote:[color=green]
                >> In article <c7qpgd$bg$1@he rcules.btintern et.com>, Matt Fletcher wrote:[color=darkred]
                >>> Hi guys,
                >>>
                >>> I am trying to allow the models in a mysql database to be ordered by the
                >>> site owner.[/color]
                >>
                >> So you should lookup the "ORDER BY" part in a SQL query.
                >>[color=darkred]
                >>> I was thinking along the lines of a <SELECT> list containing the model names
                >>> and Up and Down buttons to move the models up and down the list.
                >>>
                >>> I am unable to come up with a solution for getting the order from the list
                >>> however.[/color]
                >>
                >> You could add a column to your model table that contains the
                >> ordernumber. And then use ORDER BY order in your query.[/color]
                > ^^^^^
                >
                > Actually, I doubt very seriously you could do that since 'order' is reserved
                > word in mySQL and you would not be allowed to create a table with that column
                > name...[/color]

                I hope it's obvious that i meant to write ORDER BY ordernumber. What
                else would have the ordernumber been good for?

                And as Pedro already mentionned,



                --

                Comment

                • Matt Fletcher

                  #9
                  Re: Ordering models in a list then saving to db

                  Yes well in truth that wasn't my problem. I wanted to get the list box items
                  and save the order to the database.
                  I have now figured out that you have to use javascript to select all the
                  list items, add them to a hidden form field. Then use the hidden field
                  variable in PHP and split it up into an array of model names.
                  Now I'll update the order column in the database against the array one by
                  one.

                  Thanks for your responses,
                  MAtt

                  "Kevin Collins" <spamtotrash@to omuchfiction.co m> wrote in message
                  news:slrnca5d7q .1gi.spamtotras h@doom.unix-guy.com...[color=blue]
                  > In article <2gcq1iF1avm2U2 @uni-berlin.de>, Tim Van Wassenhove wrote:[color=green]
                  > > In article <c7qpgd$bg$1@he rcules.btintern et.com>, Matt Fletcher wrote:[color=darkred]
                  > >> Hi guys,
                  > >>
                  > >> I am trying to allow the models in a mysql database to be ordered by[/color][/color][/color]
                  the[color=blue][color=green][color=darkred]
                  > >> site owner.[/color]
                  > >
                  > > So you should lookup the "ORDER BY" part in a SQL query.
                  > >[color=darkred]
                  > >> I was thinking along the lines of a <SELECT> list containing the model[/color][/color][/color]
                  names[color=blue][color=green][color=darkred]
                  > >> and Up and Down buttons to move the models up and down the list.
                  > >>
                  > >> I am unable to come up with a solution for getting the order from the[/color][/color][/color]
                  list[color=blue][color=green][color=darkred]
                  > >> however.[/color]
                  > >
                  > > You could add a column to your model table that contains the
                  > > ordernumber. And then use ORDER BY order in your query.[/color]
                  > ^^^^^
                  >
                  > Actually, I doubt very seriously you could do that since 'order' is[/color]
                  reserved[color=blue]
                  > word in mySQL and you would not be allowed to create a table with that[/color]
                  column[color=blue]
                  > name...
                  >
                  > Kevin[/color]


                  Comment

                  Working...