SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy catagory listing as links and sublinks ??

    hi all ..

    how can i do this !?
    i have 1 table :
    Code:
    Field     | Type          
    cid         | int(7)              
    sort        |  int(3)           
    sub        |  int(7)             
    active   |  char(3)       
    listed     | char(3)         
    name     |   varchar(30)  
    link         |  blob
    if $sub is 0 then this main catagory else it`s sub, and then sub will have the same $cid for main catagory.


    what i don`t know how to figure it , it`s to list it with this way , that at start will list just the main catagories , and when the user click on one of this will list under it the sub catagories for this main cat. some thing like this

    Main1
    . sub 1
    . sub 1
    . sub 1
    Main2
    main 3
    .
    .
    etc.


    so how, am trying to do this all the day with no resulet



    THX ALOT FOR U HELP ..

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Member
    Join Date
    Jan 2002
    Location
    Sri Lanka
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Is this what you are looking for

    I'm not quite sure of what you want to do

    Take a look at this page. if what happens on the left frame is what you want to do then I will upload source code

    http://www.disciplers.com/chinese.html

  4. #4
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ArjunaK ... THX alot this what i need

  5. #5
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    freddydoesphp .. i had found this code too short for u code :
    PHP Code:
    <?
        $result 
    mysql_query("select * from catagory  order by sort");

        while(
    $row mysql_fetch_array($result)) {
            
    extract($row); //loads the array $row into variables for each column(id becomes $id)
                    //same as $id=$row["ID"]; for each column

            
    if($sub == 0) { //If the parent id is 0 then this is a main cat
                
    $tcats[$cid][] = array("cid" => $cid,
                                            
    "name" => $name,
                                            
    "sub" => $sub);
                } 
            else { 
    //Or else this is a subcat
                
    $tcats[$sub][] = array("cid" => $cid,
                                                
    "name" => $name,
                                              
    "sub" => $sub);
                }
    }



        foreach(
    $tcats as $key => $val) {
            if(
    is_array($tcats[$key])) {
                foreach(
    $tcats[$key] as $jey => $jal) {
                   
                    if(
    $tcats[$key][$jey]['sub'] == 0) {     
                        
    $this_link="?menu=sub&cid=".$tcats[$key][$jey]['cid']."&sub=".$tcats[$key][$jey]['sub']."" ;
                          
    ?>
                          
                        .   <a href ="<?=$this_link?>"><?=$tcats[$key][$jey]['name']?></a><br>
                          <?}
                          if(
    $menu=="sub"){
                          if(
    $tcats[$key][$jey]['sub'] != 0) { 
                              
    $this_sub_link="?cid=".$tcats[$key][$jey]['cid']."&sub=".$tcats[$key][$jey]['sub']."" ;
                              
    ?>
                              
                              &nbsp;&nbsp; - <a href ="<?=$this_sub_link?>"><?=$tcats[$key][$jey]['name']?></a><br>
                              
                              <?}
                              
        }
    }
    }
    }

    ?>
    am trying to modify it to make as i need links & sub links, when user click on link will list the sub links, and when he click on another link the old listed sub links will close and list the new one !

    something link what ArjunaK had done .

  6. #6
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No it doesn't close the sublink when not active, but the great thing about it is, its a class and it get be extended without too much effort to do what you need.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  7. #7
    SitePoint Member
    Join Date
    Jan 2002
    Location
    Sri Lanka
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy

    Ok I've got the code in a Zip but I cant figure out how to upload it

    Arjuna

  8. #8
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ArjunaK

    would u please ur PM ...

  9. #9
    SitePoint Guru Richi's Avatar
    Join Date
    Jul 2001
    Location
    Hu,Bp.
    Posts
    842
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i got ur email .. thx alot again, i`ll check it now !


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
  •