This content has been marked as final. Show 8 replies
You're going to need a new column in your database named displayOrder which your administrator can set the numeric order of display. Then the query would have an ORDER BY displayOrder.
The problem is, how do you keep the displayOrder updated? If you have 4 cars, display order might be 1, 2, 3, 4. But if you add a fifth car and want it displayed as the second car, what then? 1, 2, 2, 3, 4?
You might consider having categories (top, middle, bottom, for example) and give each car a category. Your ORDER BY controls which categories come first, second and third. With in each category, you could have the most recent car displayed first, etc.
I was thinking what you said (creating a new colmn for ranking).
If admin user has a text box that is for "display order" and puts the integer 3 on a new car when there are, lets say 10 cars on this page (which means 3 is already taken), how will they all change to meet new display order?
Thanks for your reply, we are on the right track.
>How will they all change to meet new display order?
One way would be to reorder the rankings whenever a record is added or updated. The attached would eliminate duplicates and produce consecutive rank numbers .. if thats important. The downside is it updates all records in the table and probably needs a transaction. I'm sure there are better ways. But this might give you some ideas..
You need to have your admin user define pretty specifically how he or she would like to have the list sorted when it is displayed. I think jdeline's suggestion about groups makes sense, unless the user wants to specify the exact order for each car. WIthin groups, you could sort by a date added field to show the newest records on the top.
It sounds, though, like maybe the need is simply to show the latest additions first (that makes a bit of sense). In that case, just add a date field for when the record was added and then use ORDER By to sort on that in descending order.
I spoke with admin. They want an up button and a down button with each "car row". Example: If up is selected with "car #4" it switches places with "car #3". If down is selected with "car #4", it switches places with "car#5". I think I could maybe figure the code out if I knew how to get the id # of the selected car.
Example: http://www.ourwebsite.com/infoPages/customCarts/index.cfm?cid4 <<this number "in this case 4".
Any help is MUCH appreciated.
So the admin wants some kind of function to set the order? How many cars are you talking about? This could make a difference in the interface you design.
If it was a relatively small number (say 10), you could list the cars and each car could have 10 radio buttons next to it, numbered 1 through 10. Every button 1 would have the same name (same "rank1") and the value would be the car ID. Same with button 2, etc. This way, you can only select one button 1, one button 2, etc. When you submit the form, you get the ID for each button number and update that car's record with the rank.
Thanks, I'm taking a look at this.