Open Source & Stuff  
  |     Main Site     |      Forum     |     Contact     |
Ajax Linked Select boxes :  forum.Salix.gr forum.Salix.gr
Comments, questions, usage, bugs. 
Goto Thread: PreviousNext
Goto: Forum ListMessage ListNew TopicSearchLog In
messageOrder by
Posted by: DonnaNj (IP Logged)
Date: November 06, 2008 08:29PM

I'm using this for a Make/Model/ Year selection

We would like the year to be descending (2008, 2007 ect) ... while the Make and Model - are still in alphabetical order.

Where/how can I add an orderby clause ?

[www.qualitypowerauto.com]

Thanks

Donna

messageRe: Order by
Posted by: panos (IP Logged)
Date: November 07, 2008 03:12AM

Hi Donna!
It’s nice to hear from you again. As I said to my mail, the first thing that comes to my mind is add_select_box's order field parameter, if your field is called make_year set the parameter like "make_year ASC" or "make_year DESC". Pls give it a try and let me know.

Best regards
Panos

messageRe: Order by
Posted by: DonnaNj (IP Logged)
Date: November 07, 2008 09:21AM

Hi thanks !

I didn't get - or somehow missed your email - so that's why I posted again.

Thank you - this worked

I'm not sure what all the columns mean yet - do you have any documentation on this ?

We're also having another bit of a mix up - I didn't think the program would work this way - but it seems to

If we pick a Make - BLUE
and then Model SQUARE
Year 2008

It returns all the BLUE/SQUARE/2008 but it also returns RED/SQUARE/2008's as well

now normally - with cars anyway - the model name is unique to that make - but in this case one model is called "PickUp Truck" and a few of the Makes have models like that - so we pick them all up.

We're going in to give them all uniqie names - but is there any other way around this ? Im thinking in the WHERE clause

say where "MAKE = $MAKE" ... to make sure we get that (I thought the program automatically did that but it doesn't seem to)

Where could I add the additional WHERE CLAUSE ? (Even if it's hard wired to the code not a variable that would be fine)

thanks

Donna

messageRe: Order by
Posted by: panos (IP Logged)
Date: November 11, 2008 08:14AM

what i had in mind when i was building this, was normalized databases.
Having uniqed ids.

let me understand your tables structure.
you have a table for makes eg
make
-------
ford
mazda

one for models

make model
---------------
ford ford1
ford ford2
mazda m1
manda pickup

and a 3rd one for items

make model year
-------------------------
ford ford1 2008
ford ford1 2004
ford ford1 2003
ford pickup 2003
ford pickup 1999
mazda m1 2004
mazda pickup 2005

or just the 3rd one?

can you give me some table structures?

messageRe: Order by
Posted by: DonnaNj (IP Logged)
Date: November 11, 2008 09:56AM

I do have the third table

But it doesn't have the make (like you I had assumed differnt makes wouldn't have the same model name)

So table 1

ford
mazda

table 2

ford escort
ford pickup
mazda m1
mazda pickup

table 3

escort 2000
escort 2001
pickup 2000
pickup 2002
m1 2002
m1 2003
pickup 2002
pickup 2003

so as you can image the program can't figure out which pickup goes with the make ... I really need to add the third column - like you have above.

But if I do how can I add the extra where so I pick

select * from table where make=$make AND model = $model and year =$year

thanks

Donna

messageRe: Order by
Posted by: panos (IP Logged)
Date: November 12, 2008 02:59AM

The proper way to do it is use primary keys and foreign keys

So table 1

pk title
---------
1 ford
2 mazda

table 2
pk fk title
-------------------------------
1 1 (for ford) escort
2 1 (for ford) pickup
3 1 (for mazda) m1
4 1 (for mazda) pickup

table 3

pk fk title year
-------------------------
1 1 escort 2000
2 1 escort 2001
3 2 pickup 2000
4 2 pickup 2002
5 3 m1 2002
6 3 m1 2003
7 4 pickup 2002
8 4 pickup 2003

this way you want have a problem



Sorry, only registered users may post in this forum.

All Rights Reserved 2006 Salix.gr  |  Design by Ades Design |  Hosting by e-emporio |  forum.Salix.gr powered by Phorum