469,926 Members | 1,901 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,926 developers. It's quick & easy.

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
Jul 17 '05 #1
8 1575
In article <c7*********@hercules.btinternet.com>, Matt Fletcher wrote:
Hi guys,

I am trying to allow the models in a mysql database to be ordered by the
site owner.
So you should lookup the "ORDER BY" part in a SQL query.
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.


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
Jul 17 '05 #2
Yeah I was thinking the same but how can i get the order from the list
Thanks
"Tim Van Wassenhove" <eu**@pi.be> wrote in message
news:2g************@uni-berlin.de...
In article <c7*********@hercules.btinternet.com>, Matt Fletcher wrote:
Hi guys,

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


So you should lookup the "ORDER BY" part in a SQL query.
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.


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

Jul 17 '05 #3
Yeah I was thinking the same but how can i get the order from the list
Thanks

"Tim Van Wassenhove" <eu**@pi.be> wrote in message
news:2g************@uni-berlin.de...
In article <c7*********@hercules.btinternet.com>, Matt Fletcher wrote:
Hi guys,

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


So you should lookup the "ORDER BY" part in a SQL query.
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.


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

Jul 17 '05 #4
Yeah I was thinking the same but how can i get the order from the list
Thanks
"Tim Van Wassenhove" <eu**@pi.be> wrote in message
news:2g************@uni-berlin.de...
In article <c7*********@hercules.btinternet.com>, Matt Fletcher wrote:
Hi guys,

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


So you should lookup the "ORDER BY" part in a SQL query.
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.


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

Jul 17 '05 #5
In article <2g************@uni-berlin.de>, Tim Van Wassenhove wrote:
In article <c7*********@hercules.btinternet.com>, Matt Fletcher wrote:
Hi guys,

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


So you should lookup the "ORDER BY" part in a SQL query.
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.


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

^^^^^

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
Jul 17 '05 #6
Kevin Collins wrote:
In article <2g************@uni-berlin.de>, Tim Van Wassenhove wrote:
You could add a column to your model table that contains the
ordernumber. And then use ORDER BY order in your query.

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...


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 :
Jul 17 '05 #7
In article <sl************************@doom.unix-guy.com>, Kevin Collins wrote:
In article <2g************@uni-berlin.de>, Tim Van Wassenhove wrote:
In article <c7*********@hercules.btinternet.com>, Matt Fletcher wrote:
Hi guys,

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


So you should lookup the "ORDER BY" part in a SQL query.
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.


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

^^^^^

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...


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,
http://dev.mysql.com/doc/mysql/en/Legal_names.html
--
http://home.mysth.be/~timvw
Jul 17 '05 #8
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" <sp*********@toomuchfiction.com> wrote in message
news:sl************************@doom.unix-guy.com...
In article <2g************@uni-berlin.de>, Tim Van Wassenhove wrote:
In article <c7*********@hercules.btinternet.com>, Matt Fletcher wrote:
Hi guys,

I am trying to allow the models in a mysql database to be ordered by the site owner.
So you should lookup the "ORDER BY" part in a SQL query.
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.


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

^^^^^

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

Jul 17 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

15 posts views Thread by Kay Schluehr | last post: by
2 posts views Thread by Ken Durden | last post: by
3 posts views Thread by marc | last post: by
1 post views Thread by Matt Roberts | last post: by
20 posts views Thread by Brian Tkatch | last post: by
21 posts views Thread by John Salerno | last post: by
5 posts views Thread by =?Utf-8?B?VG9t?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.