Current location: Hot Scripts Forums » Programming Languages » PHP » Drop Down menu order


Drop Down menu order

Reply
  #1 (permalink)  
Old 08-20-04, 02:38 AM
peterc peterc is offline
New Member
 
Join Date: Aug 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Drop Down menu order

I hope someone here can help me with this. I am trying to build an online store using cubecart. I have been unable to get a fix from their forum.

The programm allows me to build a drop down menu by selecting values already input - i guess into the database.

I try to build the drop down menu using values 8,10,12,14,16. When I look at the page it has built the drop down order is 10,12,8,14,16. I have tried this with various other values and the drop down order never appears as I want it (ascending numerical order - lowest value at the top of the drop down)

Can someone tell me what bit of code I need to put into the page that builds this menu to acheive the desired order?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 08-20-04, 03:23 AM
darkfreak's Avatar
darkfreak darkfreak is offline
Newbie Coder
 
Join Date: Jun 2004
Location: Kuopio, Finland, Europe
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
I have never used cubecart, so I know absolutely nothing about it. However, here's one general suggestion which may help you. Use it with care and, of course, at your own risk.

The values are probably sent to the drop-down list generator function as an array. You should locate this function in the code and apply the sort() or arsort() function on the array before the drop-down list is generated. Which function? It depends on the array type but I guess it won't hurt to try them both.

Quote:
bool sort ( array array [, int sort_flags])

This function sorts an array. Elements will be arranged from lowest to highest when this function has completed.

Note: This function assigns new keys for the elements in array. It will remove any existing keys you may have assigned, rather than just reordering the keys.

Returns TRUE on success or FALSE on failure.

arsort
(PHP 3, PHP 4 )

arsort -- Sort an array in reverse order and maintain index association
Description
bool arsort ( array array [, int sort_flags])


This function sorts an array such that array indices maintain their correlation with the array elements they are associated with. This is used mainly when sorting associative arrays where the actual element order is significant.

Returns TRUE on success or FALSE on failure.


Sorting type flags:

SORT_REGULAR - compare items normally

SORT_NUMERIC - compare items numerically

SORT_STRING - compare items as strings
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a drop down menu ? ? ? Spreegem PHP 4 03-09-05 10:34 AM
Drop Down Menu populated by Database maweber98 PHP 5 08-20-04 11:43 AM
Need help with populating drop down menu... NCC1701 PHP 0 04-28-04 08:10 AM
drop down menu problem !!! nurqeen PHP 1 02-08-04 09:07 PM
putting content in a drop down menu tom PHP 7 07-04-03 03:25 PM


All times are GMT -5. The time now is 12:22 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.