473,804 Members | 2,246 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1698
In article <c7*********@he rcules.btintern et.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*********@he rcules.btintern et.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*********@he rcules.btintern et.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*********@he rcules.btintern et.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*********@he rcules.btintern et.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************ ************@do om.unix-guy.com>, Kevin Collins wrote:
In article <2g************ @uni-berlin.de>, Tim Van Wassenhove wrote:
In article <c7*********@he rcules.btintern et.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*********@to omuchfiction.co m> wrote in message
news:sl******** *************** *@doom.unix-guy.com...
In article <2g************ @uni-berlin.de>, Tim Van Wassenhove wrote:
In article <c7*********@he rcules.btintern et.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
587
by: Ken Fine | last post by:
(originally posted to one of macromedia's groups; no help, so hopefully someone here can help me out. I'm using VBScript ASP.) When designing administrative interfaces to websites, we often need to provide users with a mechanism to change the order of items that are listed on the page.For example, the _New York Times_ website (http://www.nytimes.com) lists a bunch of top news articles, and normally these are ordered by purely mechanical...
15
1754
by: Kay Schluehr | last post by:
Here might be an interesting puzzle for people who like sorting algorithms ( and no I'm not a student anymore and the problem is not a students 'homework' but a particular question associated with a computer algebra system in Python I'm currently developing in my sparetime ). For motivation lets define some expression class first: class Expr: def __init__(self, name=""):
2
1847
by: Ken Durden | last post by:
Is there any way to control ordering of items in intellisense via attributes? For example, I have the following enum: public enum ESeverity { Acceptable, Low, Medium,
3
1441
by: marc | last post by:
I want to create a strongly typed collection and use DictionaryBase I add a number of objects but when i loop through the list the data is ordered in a strange maner. How is this possible? Can anybody tell my why the order gets changed? Thanks Marc '***************** OUTPUT **************************
1
5893
by: Matt Roberts | last post by:
Please accept my apologies if this is answered elsewhere in the archives or docs but I have searched without luck. I've always assumed that default ordering of selects are based on a first in first out principle and that this remains true at the row level despite edits to columns. However I'm dealing with a case where this doesn't seem to hold true. The ordering has changed over time. Its difficult for me to gauge whether the data has...
20
2504
by: Brian Tkatch | last post by:
An ORDER BY a simple-integer inside a FUNCTION, results in SQL0440N, unless the FUNCTION expects an INTEGER as its parameter. For example: DECLARE GLOBAL TEMPORARY TABLE A(A CHAR(1)) INSERT INTO SESSION.A VALUES ('a'), ('b') CREATE FUNCTION A(A char(1)) RETURNS char(1) DETERMINISTIC NO EXTERNAL ACTION RETURN A SELECT A FROM SESSION.A ORDER BY A(1) DROP FUNCTION A DROP TABLE SESSION.A
21
1664
by: John Salerno | last post by:
If I want to make a list of four items, e.g. L = , and then figure out if a certain element precedes another element, what would be the best way to do that? Looking at the built-in list functions, I thought I could do something like: if L.index('A') < L.index('D'): # do some stuff But I didn't know if maybe there was a preferred method for this type of
23
11327
by: illegal.prime | last post by:
Hi all, is there a key value collection in .Net that maintains the ordering in which I add items. I'm finding that I'm creating a number of classes that contain a name and then some object. I would prefer just to use some collection that maintains the ordering in which I add things (like ArrayList), but that maps a key to a value. I thought NameValueCollection was the right one - but it doesn't guarantee ordering.
5
2672
by: =?Utf-8?B?VG9t?= | last post by:
Cannot not seem to make any sense of the order that my key/values end up in when added to the Hashtable...ideally, I would like to be able to sort the keys/values...but not thinking it is possible. For those who are sure going to ask why I am asking this....I use the Hashtable for conveniently cross-referencing pairs of information...and I am now trying to populate a combo box based on the hashtable contents using the key as the combo...
0
9714
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10350
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10351
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10096
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9174
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7638
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3834
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.