Jump to content

Order of items showing in nav bar


kurt.santo
 Share

Recommended Posts

Having a database with a table listing the navigation items for a website: Is there any way that I can choose the order in which the sub-items appear? The order is not related to id, alphabet and is simple a matter of of me saying ok I have this new item, which should appear in in range 1 and should be placed in between item 2 and item 3 of this range for example...Kurt

Link to comment
Share on other sites

You need a field in the database for display order.
That makes sense. But how easy would that be to maintain? I mean, if I have two products, one having display order 32 and one 33: How would I insert the new product in between, so that it has display order 33 and the display order of all other ones increases by one (or decreases by one if one is deleted/or change display order when you change you mind)?Kurt
Link to comment
Share on other sites

I'm working on an application where you add items individually and then can reorder them by moving an item up or down. Moving an item causes the display orders for that item and the next or previous item to switch, so that the display order for the next or previous is changed by one (up or down), and then the display order for the selected item is changed to what the other one used to be.There's no "magic" way to do this, you just need to reorder everything. If you want to insert an item at #32 you can do this to update everything else:UPDATE table SET display_order = display_order + 1 WHERE display_order >= 32

Link to comment
Share on other sites

I'm working on an application where you add items individually and then can reorder them by moving an item up or down. Moving an item causes the display orders for that item and the next or previous item to switch, so that the display order for the next or previous is changed by one (up or down), and then the display order for the selected item is changed to what the other one used to be.There's no "magic" way to do this, you just need to reorder everything. If you want to insert an item at #32 you can do this to update everything else:UPDATE table SET display_order = display_order + 1 WHERE display_order >= 32
That is great and would solve my problem... Just another question relating to same table: Is there a way to populate my table in a quicker way that having to manually enter the whole schebang as INSERT INTO tablename (column1, column2, column3, column4, column5) VALUES ('value1', 'value2' 'value3' 'value4' 'value5'), ('value1', 'value2' 'value3' 'value4' 'value5'), ('value1', 'value2' 'value3' 'value4' 'value5') and and and. I use Dreamweaver and have PHP, MySQL and the Apache Web Server installed on my machine. I start using simple PHP files, which works fine with Dreamweaver, but I am not so happy with the MySQL Command Line Client. I have used Excel a lot (I know, I know, please no comments;-)) and wondered if there is any good program out there that would make it newbies as me a bit easier (for now, just the MySQL)...Kurt
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...