SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Guru
    Join Date
    Nov 2008
    Posts
    619
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    re-ordering the sub categories

    hi all

    i am creating a navigation list(Categories + sub categories) in the left bar of my website.

    Each Category has around 5-7 sub categories under them.

    Code:
    MOBILE PHONES (this is category name)
    1) Nokia (these below are sub categories)
    2) Samsung
    3) Sony
    4) Motorola
    5) Apple
    6) Blackberry
    at present they are displayed in a general loop acording to the number they were entered.

    now i want to change the "display order" of sub categories.

    means I want to move
    Code:
    "Sony" at No. 1
    "Blackberry at No.2
    "Samsung" at No. 3
    at present this is my query
    PHP Code:
    $leftqry="select * from dealer_table where category_id=1";
    $leftresult=mysql_query($leftqry);
    while(
    $leftrow mysql_fetch_array($leftresult))
    {
    echo 
    "<tr>";
    echo 
    "<td>" "<a class='leftnav' title='".$dname"-"$cname"' href='http://localhost/mobiles-".$leftrow['dealer_id'] . "-" .$leftrow['category_id'] ."-".$dname."-".$cname.".html""'>&raquo; &nbsp;" .$leftrow['dealer_name']. "</a></td>";
    echo 
    "</tr>";

    what should i do

    vineet

  2. #2
    SitePoint Enthusiast Sam32's Avatar
    Join Date
    Sep 2010
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How the list should be presented? Any specific criterion?

  3. #3
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,412
    Mentioned
    149 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by Sam32 View Post
    How the list should be presented? Any specific criterion?
    Indeed. In order to order the data from the table in a specific order (doh) the table must have a column that contains the order criterium. So if you want to be able to change the order at will, you'll need to have a 'listorder' column and add ' ORDER BY listorder' to your query.

  4. #4
    SitePoint Guru
    Join Date
    Nov 2008
    Posts
    619
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    hi guido

    can me explain me a lit bit more about what kind of data should be entered in "listorder" column ?

    shall i enter numeric data and then i will be updating this column to re-order my list?

    vineet

  5. #5
    SitePoint Enthusiast Sam32's Avatar
    Join Date
    Sep 2010
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There's no need to add another column if he wants to order the list based, for instance, on a number of sales criterion. That's why I asked.

  6. #6
    SitePoint Guru
    Join Date
    Nov 2008
    Posts
    619
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Sam32 View Post
    There's no need to add another column if he wants to order the list based, for instance, on a number of sales criterion. That's why I asked.
    hi sam

    there is no reason for having particular creteria for presenting.

    its just that i think "Sony" is first preference for my clients and then 2nd is "Blackberry".

    so i need to show "Sony" on No.1 and Blackberry at No. 2 and so on

    vineet

    vineet



    vineet

  7. #7
    SitePoint Enthusiast Sam32's Avatar
    Join Date
    Sep 2010
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by vinpkl View Post
    hi sam

    there is no reason for having particular creteria for presenting.

    its just that i think "Sony" is first preference for my clients and then 2nd is "Blackberry".

    so i need to show "Sony" on No.1 and Blackberry at No. 2 and so on

    vineet

    vineet



    vineet
    Use the approach suggested by Guido then.

  8. #8
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,412
    Mentioned
    149 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by vinpkl View Post
    shall i enter numeric data and then i will be updating this column to re-order my list?
    Yes.

  9. #9
    SitePoint Guru
    Join Date
    Nov 2008
    Posts
    619
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by guido2004 View Post
    Yes.
    thanks guido

    vineet


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •