SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 31
  1. #1
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Looking for a Query that fits the fallowing explanation, Help please.....

    I will explain in details what I want to achieve first, and then I will post the code explaining and clarifying bit by bit for your understanding. in other words you will be able to see what can be done about the purpose or achievements i want to do.

    What I want to achieve is:

    First, I have three headings and within each of the three headings you will find different subheadings. The subheadings will only appears once an user click on any of the three headings when one heading is clicked on then the subheadings display downward. for example:

    Illustration 1
    Sneakers
    1. Nike
    2. Adidas
    3. Fila

    Boots
    DressShoes
    Explanation of Illustration 1.


    In this illustration there are three headings; Sneakers, Boots and DressShoes. The one clicked on is Sneakers and it shows or display a list of subheadings. In this case we have three subheadings Nike, Addidas and Fila. if you notice the others Headings stay closed containing its subheadings within because they haven't been clicked on. The set up of the code or what the code I have built so far does as fallows:

    1- Enter the web address and the three headings appears

    Sneakers
    Boots
    DressShoes
    2-A user click on a heading in this case the Sneakers heading and it display the subheadings of that heading called Sneakers and leave the subheadings of that heading (Sneakers) displayed, If you notice the others heading stay closed containing its subheadings inside but not visible.

    Sneakers
    1. Nike
    2. Addias
    3. Fila

    Boots
    DressShoes
    3-From this point if a user click on any other heading let say Boots

    Sneakers
    Boots
    • Timberland
    • Deakers
    • Western Boots

    DressShoes
    4 Then the subheadings of the previous clicked on heading Sneakers disappear in other words close the previous heading along with its subheadings,
    5-And then display the subheadings of the recent clicked on heading in this case Boots and leave it displayed. if you notice the Sneakers and DressShoes stay closed containing its subheadings inside but not visible to the users at this point.

    Second part
    My Purpose is:

    The subheadings as I said will only display downward when you click on one of the headings which is ok. It display the subheadings and when I click on one of the subheading then it shows the content of the selected subheading in a table that I have styled to be at the right side of the page.
    Illustration 2

    Sneakers
    1. Nike
    2. Addias
    3. Fila

    Boots
    DressShoes
    Explanation of the illustration 2 if for example the Nike subheading is clicked on then the content would displayed. The content would be placed in the table to the right of the page.
    1-Air jordan
    2-Air force
    3-Air jordan D-Zero
    4-Jordan true Flight Man
    5-Lebroms Nike
    As it display the content of the subheading *Nike it closes all the headings and comeback to the default state leaving the content of the *Nike display.

    Illustration 3

    leave the Displayed content of the *Nike subheading but .

    1-Air jordan
    2-Air force
    3-Air jordan D-Zero
    4-Jordan true Flight Man
    5-Lebroms Nike
    But the headings placed in a table at the left of the page comeback to the Default state.


    Sneakers
    Boots
    DressShoes

    in others words, it display the content of the subheading but it doesn't leave the subheadings displayed underneath the heading selected which in this case was Sneakers.So that if a user want to select or choose another subheading other than the *Nike subheading within the heading Sneakers, to display the content of any other desired subheading in the table placed to the right of the page, the user has to open the Sneakers heading again and choose any other subheading than the *Nike for instance *Adidas to see Adidas content.

    Instead I want to display the headings as default just as it is, and once an user clicked on a heading then the subheadings underneath that heading display. Onto that point that's how the actual coding I have now is set up. But after that point I want the subheadings to display the content in the table styled at the right side of the web page and at the same time I want the subheadings underneath the clicked on heading in this case *Nike *Adidas *Fila to stay displayed and visible after an user click on one of the subheadings to display its content in the table, instead avoid the headings coming back to the default state which disappear all the subheadings underneath that subheading in this case Sneakers.

    default state:

    Sneakers
    Boots
    DressShoes

    Sneakers
    1. Nike
    2. Addias
    3. Fila

    Boots
    DressShoes
    Click on the *Nike subheading and it shows the content of *Nike but it comes
    back to:

    default state
    Sneakers
    Boots
    DressShoes
    Instead of leaving the subheading of the Heading Sneakers visible and still shows the content.

    Sneakers
    1. Nike
    2. Addias
    3. Fila

    Boots
    DressShoes

    1-Air jordan
    2-Air force
    3-Air jordan D-Zero
    4-Jordan true Flight Man
    5-Lebroms Nike
    End of the purpose or what I want to achieve in php.

    Third part

    I have re-explained the purpose above enough, so that you guys can understand it without leaving doubts in your head. and If you still don't understand let me know I just here to clarify I need help.

    Now that the purpose is clear let me explain the code set up I have so far.

    PHP Code:
    <?php

    if(isset($_GET['shoesubject'])){
    $sel_subject $_GET['shoesubject'];
    $sel_shoe "";
    } elseif(isset(
    $_GET['shoe])){
    $sel_subject = "";
    $sel_shoe = $_GET['
    shoe'];
    }else {
    $sel_subject= ""; 
    $sel_shoe = "";
             
    }

    ?>
    These are the values I have (isset) on the top of the document. The $_GET variable which I understand function as a variable that scatter its values through out the whole document right?. That what I understand the $_GET variable does. As explain you the code you will see the values scattered through the document.

    The next bit of code it's what fallows after I (isset) the variables
    PHP Code:
    <ul class="menu">
       <?php   
      $query 
    "SELECT * 
                    FROM menusubjects "
    //headings are called on this query
                            
      
    $menusubject_set mysql_query($query$connection);
      if(!
    $menusubject_set){
      die(
    "Database query failed:" mysql_error());
      }while(
    $menusubject mysql_fetch_array($menusubject_set)){ // this while loop display the list of heading which are three 
      
    echo "<li"
      if (
    $menusubject["id"] == $sel_subject) {
      echo 
    " class=\"selected\"";
      }
      echo 
    "><a href=\"example1.php?subject=" urlencode($menusubject["id"]) ."\";>{$menusubject["Subject"]}</a></li>"
       
      
    $query "SELECT * 
                  FROM regularmenu  // these are the subheadings and they display beneath the headings
                WHERE menusubject_id = 
    {$menusubject["id"]}";
                
      
    $regularmenu_set mysql_query($query$connection);
      if(!
    $regularmenu_set){die("Database query failed:" mysql_error());} 
      echo 
    "<ul class=\"submenu\">"
      if (
    $menusubject["id"] == $sel_subject) { // this if statement stays that the heading will only display the subheadings withing the next while loop 
      
    while($rmenu mysql_fetch_array($regularmenu_set)){
      echo 
    "<li"
      if (
    $rmenu["id"] == $sel_menu) {
      echo 
    " class=\"selected\""
      } 
      echo 
    "><a href=\"example1.php?menu=" urlencode($rmenu["id"]) ."\";>{$rmenu["platename"]}</a></li>";  }
      } 
      
    echo 
    "</ul>"
      }
       
     
     
    ?>
     </ul> </table>
    Now my final question is, where within this code I could place a condition where subheadings display its content and at the same time the subheadings stay displayed underneath the headings which is the final part of the purpose I described and detailed above.

    There are a final part of the entire php code i have which contain a query that calls the content of the subheadings which will be displayed in a table found within this final part of the php code set up in this file, and it goes as follows:

    PHP Code:
    <?php $query "SELECT shoe.shoename, shoe.price, shoe.moreinfo 
    FROM shoe
    WHERE
    shoe_kind = "
    . (int) $_GET['shoe']; // $_GET value I extract it from the (isset) selection at the top of the code. This condition will show the content if the shoe_kind is == to $_GET value. I don't know if the query or purpose described above need a query to be place before this query or after this query and table found on this final part of my code.
    echo $query 
    $result 
    mysql_query($query$connection);
    while (
    $content mysql_fetch_array($result)) {
    echo 
    "<table style=\"float:left\">
    <td width=\"150\" style=\"text-align:center;\">" 
    $row['shoename'] . "</td>
    <tr>
    <td height=\"100\" width=\"100\"   style=\"position:relative;\">
    <img src=\"../images/shoesname.jpg\" alt=\"sd\" width=\"97\" height=\"80\"  border=\"1\" style=\"border-color:#FF6600;\" />
    </td></tr>
    <tr>
    <td width=\"5\" height=\"21\" ></td><td>" 
    $row['price'] . "</td>
    </tr>
    <td>" 
    $row['moreinfo'] . "</td>
    </table>"
    ;

    ?>
    <?php
    mysql_close($connection);
    ?>

    Help please...
    Again where could I locate a query and condition

    where I Click on subheading in this case the *Nike subheading it shows the content of *Nike but instead of coming back to:

    default state

    Sneakers
    Boots
    DressShoes

    Instead of leaving the subheadings of the Heading Sneakers visible and still shows the content like this.

    Heading and subheadings in a table to the left of the page

    Sneakers
    1. Nike
    2. Addias
    3. Fila

    Boots
    DressShoes
    This is what display in the table at the right of the page

    1-Air jordan
    2-Air force
    3-Air jordan D-Zero
    4-Jordan true Flight Man
    5-Lebroms Nike
    Help please....

  2. #2
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You've basically described an accordion menu. There are several available for jQuery.

  3. #3
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I want an accordion menu but instead of closing after choosing one of its subheadings I want the subheadings to still display and only make the accordion effect if another heading is click on.

    If you can display a query where this can be possible.

    I will appreciate it thank you.

    I don't want a normal accordion menu but one that meets the conditions i have set up above as well.

    Drop some help please.

  4. #4
    We're from teh basements.
    Join Date
    Apr 2007
    Posts
    1,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The SQL query has nothing to do with how the accordion menu behaves. The menu is defined in JavaScript on the client side.

  5. #5
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you World wide Weird

    The behavior of the php code found above display an accordion menu. But the purpose still not met. Well now i know It is not a query problem but a proper set up of the code. Please see the code above and see how can you form some subjection to modify the code toward the fallows:

    Where I Click on subheading in this case the *Nike subheading it shows the content of *Nike but instead of coming back to:

    default state
    Quote:

    Sneakers
    Boots
    DressShoes

    Instead of leaving the subheadings of the Heading Sneakers visible and still shows the content like this.

    Heading and subheadings in a table to the left of the page

    Sneakers

    1. Nike
    2. Addias
    3. Fila

    Boots
    DressShoes
    This is what display in the table at the right of the page
    Quote:


    1-Air jordan
    2-Air force
    3-Air jordan D-Zero
    4-Jordan true Flight Man
    5-Lebroms Nike

    Help please....

    This is the code that mostly form the Accordion menu:

    PHP Code:
    <ul class="menu">
     <?php   
      $query 
    "SELECT * 
                    FROM menusubjects "
    //headings are called on this query                   
      
    $menusubject_set mysql_query($query$connection);
      if(!
    $menusubject_set){
      die(
    "Database query failed:" mysql_error());
      }while(
    $menusubject mysql_fetch_array($menusubject_set)){ // this while loop display the list of heading which are three 
      
    echo "<li"
     if (
    $menusubject["id"] == $sel_subject) {
    echo 
    " class=\"selected\"";
      }
      echo 
    "><a href=\"example1.php?subject=" urlencode($menusubject["id"]) ."\";>{$menusubject["Subject"]}</a></li>"

       

      
    $query "SELECT * 
                  FROM regularmenu  // these are the subheadings and they display beneath the headings
                WHERE menusubject_id = 
    {$menusubject["id"]}";

      
    $regularmenu_set mysql_query($query$connection);
      if(!
    $regularmenu_set){die("Database query failed:" mysql_error());} 
    echo 
    "<ul class=\"submenu\">"
      if (
    $menusubject["id"] == $sel_subject) { // this if statement stays that the heading will only display the subheadings withing the next while loop 
      
    while($rmenu mysql_fetch_array($regularmenu_set)){
      echo 
    "<li"
      if (
    $rmenu["id"] == $sel_menu) {
      echo 
    " class=\"selected\""
      } 
      echo 
    "><a href=\"example1.php?menu=" urlencode($rmenu["id"]) ."\";>{$rmenu["platename"]}</a></li>";  }

      } 
    echo 
    "</ul>"

      }

     
    ?>

     </ul> </table>
    What could I do to arrange this code so that the subheadings of the heading still display whether a users click on one subheading instead of performing the normal accordion behavior which closes the subheadings once a heading is clicked on.

  6. #6
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,194
    Mentioned
    17 Post(s)
    Tagged
    4 Thread(s)
    quick and dirty:

    echo "><a href=\"example1.php?subject=".urlencode($menusubject["id"])."&menu=" . urlencode($rmenu["id"]) ."\";>{$rmenu["platename"]}</a></li>"; }

    pass the subject with the menu for subheadings.

  7. #7
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you oddz

    When I paste the code below

    It brings a Parse error: parse error, expecting `','' or `';'' on line 66

    PHP Code:
    echo "><a href=\"example1.php?subject=".urlencode($menusubject["id"])."&menu=" urlencode($rmenu["id"]) ."\";>{$rmenu["platename"]}</a></li>"
    // this is line 66 

  8. #8
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,194
    Mentioned
    17 Post(s)
    Tagged
    4 Thread(s)
    PHP Code:
    echo '><a href="example1.php?subject='.urlencode($menusubject['id']).'&menu='.urlencode($rmenu["id"]).'">'.$rmenu['platename'].'</a></li>'

  9. #9
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The parse error stills.

    Just want you to know that at this point the $rmenu variable hasn't been defined, it is defined after the next query that fallows this code line. I don't know if that will affect the performance even though that is not the error at his moment, the error consist still in a parse error.

  10. #10
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My bad let me see if I can fix the parse error wait

  11. #11
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,194
    Mentioned
    17 Post(s)
    Tagged
    4 Thread(s)
    Then that isn't going to work. Its a little difficult to read you code. Consider using indenting it really helps readability.

  12. #12
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it still

  13. #13
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,194
    Mentioned
    17 Post(s)
    Tagged
    4 Thread(s)
    Could you post the create table for these tables: (menusubjects and regularmenu)

  14. #14
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,194
    Mentioned
    17 Post(s)
    Tagged
    4 Thread(s)
    You can go ahead and give this a go although it is untested. I think the logic is what you want though.

    PHP Code:
    $submenu false;
    $cat = isset($_GET['subject']) && is_numeric($_GET['subject'])?$_GET['subject']:null;
    $prod = isset($_GET['menu']) && is_numeric($_GET['menu'])?$_GET['menu']:null;

    $sql 'SELECT id,Subject FROM menusubjects;';
    $result mysql_query($sql);

    if(
    $result && mysql_num_rows($result)!=0) {
        
        echo 
    '<ul id="nav-categories">';
        
        while(
    $row mysql_fetch_assoc($result)) {
            
            
    $uri 'example1.php?subject='.urlencode($row['id']);
            
    $class = !is_null($cat) && $cat==$row['id']?' class="selected"':'';
            
            echo 
    "\t",'<li',$class,'><a href="',$uri,'">',$row['Subject'].'</a>';
                
            if(
    $submenu==false && !is_null($cat)) {
                    
                
    $sql2 'SELECT id,platename FROM regularmenu WHERE menusubject_id = '.mysql_real_escape_string($cat).';';
                
    $result2 mysql_query($sql2);
                    
                if(
    $result2 && mysql_num_rows($result2)!=0) {
                        
                    echo 
    "\n\t\t",'<ul class="submenu">',"\n";    
                    
                    while(
    $row2 mysql_fetch_assoc($result2)) {
                        
                        
    $uri2 $uri.'&menu='.urlencode($row2['id']);
                        
    $class2 = !is_null($prod) && $prod==$row2['id']?' class="selected"':'';
                        
                        echo 
    "\t\t\t",'<li',$class,'><a href="',$uri2,'">',$row2['platename'],'</a></li>',"\n";
                    
                    }
                    
                    echo 
    "\t\t",'</ul> <!-- end of ul.submenu -->',"\n";    
                        
                }
                    
                
    $submenu true;
                
            }
                
            echo 
    '</li>',"\n";
            
        }
            
        echo 
    '</ul> <!-- end of ul#nav-categories -->',"\n";


  15. #15
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok Let me do that

  16. #16
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is the Menusubjects table.


    id | Subject

    1 | Sneakers
    2 | Boots
    3 | Dressshoes

    The regularmenu or Submenus table goes like this



    id - menusubject_id - platename
    1 - 1 - Nike
    2 - 1 - Adidas
    3 - 1 - Fila


    and The last table is Shoestore the last one


    id | kind_id | shoename | Price | Moreinfo

    1 | 1 | Air jordan | 10.95 | More Info
    2 | 1 | Air Force | 7.95 | More Info
    3 | 1 | Air Jordan D-Zero| 8.50 | More Info
    4 | 1 | Lebrom Nike | 8.95 | More Info

  17. #17
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    &&

    What this double sign means?

    I guess it means "or" right?

  18. #18
    @php.net Salathe's Avatar
    Join Date
    Dec 2004
    Location
    Edinburgh
    Posts
    1,397
    Mentioned
    65 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by co.ador View Post
    &&

    What this double sign means?

    I guess it means "or" right?
    It's a logical and operator.
    Salathe
    Software Developer and PHP Manual Author.

  19. #19
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you Oddz the code work but,

    When I open the headings after the first heading then the content or submenus of the heading after the first heading open underneath the first heading instead of opening in its respective heading....

    example 1 open sneakers and it open its submenus underneath showed in the illustration below.


    Sneakers

    1. Nike
    2. Addias
    3. Fila
    Boots
    DressShoes


    Example 2 open the heading boots and then the submenus of boots open inside Sneakers.


    I haven't analize the code fully cause i am at work but I ask for you opinion guys.

    Sneakers
    * Timberland
    * Deakers
    * Western Boots
    Boots
    DressShoes


    Your code work fine...

  20. #20
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,194
    Mentioned
    17 Post(s)
    Tagged
    4 Thread(s)
    Missed the comparison.

    PHP Code:
    $submenu false;
    $cat = isset($_GET['subject']) && is_numeric($_GET['subject'])?$_GET['subject']:null;
    $prod = isset($_GET['menu']) && is_numeric($_GET['menu'])?$_GET['menu']:null;

    $sql 'SELECT id,Subject FROM menusubjects;';
    $result mysql_query($sql);

    if(
    $result && mysql_num_rows($result)!=0) {
        
        echo 
    '<ul id="nav-categories">';
        
        while(
    $row mysql_fetch_assoc($result)) {
            
            
    $uri 'example1.php?subject='.urlencode($row['id']);
            
    $class = !is_null($cat) && $cat==$row['id']?' class="selected"':'';
            
            echo 
    "\t",'<li',$class,'><a href="',$uri,'">',$row['Subject'].'</a>';
                
            if(
    $submenu==false && !is_null($cat) && $cat == $row['id']) {
                    
                
    $sql2 'SELECT id,platename FROM regularmenu WHERE menusubject_id = '.mysql_real_escape_string($cat).';';
                
    $result2 mysql_query($sql2);
                    
                if(
    $result2 && mysql_num_rows($result2)!=0) {
                        
                    echo 
    "\n\t\t",'<ul class="submenu">',"\n";    
                    
                    while(
    $row2 mysql_fetch_assoc($result2)) {
                        
                        
    $uri2 $uri.'&menu='.urlencode($row2['id']);
                        
    $class2 = !is_null($prod) && $prod==$row2['id']?' class="selected"':'';
                        
                        echo 
    "\t\t\t",'<li',$class,'><a href="',$uri2,'">',$row2['platename'],'</a></li>',"\n";
                    
                    }
                    
                    echo 
    "\t\t",'</ul> <!-- end of ul.submenu -->',"\n";    
                        
                }
                    
                
    $submenu true;
                
            }
                
            echo 
    '</li>',"\n";
            
        }
            
        echo 
    '</ul> <!-- end of ul#nav-categories -->',"\n"

  21. #21
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $submenu false;
    $cat = isset($_GET['subject']) && is_numeric($_GET['subject'])?$_GET['subject']:null;
    $prod = isset($_GET['menu']) && is_numeric($_GET['menu'])?$_GET['menu']:null;

    $sql 'SELECT id,Subject FROM menusubjects;';
    $result mysql_query($sql);

    if(
    $result && mysql_num_rows($result)!=0) {
        
        echo 
    '<ul id="nav-categories">';
        
        while(
    $row mysql_fetch_assoc($result)) {
            
            
    $uri 'example1.php?subject='.urlencode($row['id']);
            
    $class = !is_null($cat) && $cat==$row['id']?' class="selected"':'';
            
            echo 
    "\t",'<li',$class,'><a href="',$uri,'">',$row['Subject'].'</a>';
                
            if(
    $submenu==false && !is_null($cat) && $cat == $row['id']) { // line 58
                    
                
    $sql2 'SELECT id,platename FROM regularmenu WHERE menusubject_id = '.mysql_real_escape_string($cat).';';
                
    $result2 mysql_query($sql2);
                    
                if(
    $result2 && mysql_num_rows($result2)!=0) {
                        
                    echo 
    "\n\t\t",'<ul class="submenu">',"\n";    
                    
                    while(
    $row2 mysql_fetch_assoc($result2)) {
                        
                        
    $uri2 $uri.'&menu='.urlencode($row2['id']);
                        
    $class2 = !is_null($prod) && $prod==$row2['id']?' class="selected"':'';
                        
                        echo 
    "\t\t\t",'<li',$class,'><a href="',$uri2,'">',$row2['platename'],'</a></li>',"\n";
                    
                    }
                    
                    echo 
    "\t\t",'</ul> <!-- end of ul.submenu -->',"\n";    
                        
                }
                    
                
    $submenu true;
                
            }
                
            echo 
    '</li>',"\n";
            
        }
            
        echo 
    '</ul> <!-- end of ul#nav-categories -->',"\n 
    When I refresh it in the browser it says that there is a parse error on line 58 I don't get it. It was working before pretty good.

  22. #22
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The parse error was a . instead of a , on line 57 of the code....


    and the comparison you missed worked as well, now the subheadings are being assigned to its respective heading.

  23. #23
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,194
    Mentioned
    17 Post(s)
    Tagged
    4 Thread(s)
    left out the parentheses.

    PHP Code:
    $submenu false;
    $cat = isset($_GET['subject']) && is_numeric($_GET['subject'])?$_GET['subject']:null;
    $prod = isset($_GET['menu']) && is_numeric($_GET['menu'])?$_GET['menu']:null;

    $sql 'SELECT id,Subject FROM menusubjects;';
    $result mysql_query($sql);

    if(
    $result && mysql_num_rows($result)!=0) {
        
        echo 
    '<ul id="nav-categories">';
        
        while(
    $row mysql_fetch_assoc($result)) {
            
            
    $uri 'example1.php?subject='.urlencode($row['id']);
            
    $class = !is_null($cat) && $cat==$row['id']?' class="selected"':'';
            
            echo 
    "\t",'<li',$class,'><a href="',$uri,'">',$row['Subject'].'</a>';
                
            if(
    $submenu==false && !is_null($cat) && $cat == $row['id']) {
                    
                
    $sql2 'SELECT id,platename FROM regularmenu WHERE menusubject_id = '.mysql_real_escape_string($cat).';';
                
    $result2 mysql_query($sql2);
                    
                if(
    $result2 && mysql_num_rows($result2)!=0) {
                        
                    echo 
    "\n\t\t",'<ul class="submenu">',"\n";    
                    
                    while(
    $row2 mysql_fetch_assoc($result2)) {
                        
                        
    $uri2 $uri.'&menu='.urlencode($row2['id']);
                        
    $class2 = !is_null($prod) && $prod==$row2['id']?' class="selected"':'';
                        
                        echo 
    "\t\t\t",'<li',$class,'><a href="',$uri2,'">',$row2['platename'],'</a></li>',"\n";
                    
                    }
                    
                    echo 
    "\t\t",'</ul> <!-- end of ul.submenu -->',"\n";    
                        
                }
                    
                
    $submenu true;
                
            }
                
            echo 
    '</li>',"\n";
            
        }
            
        echo 
    '</ul> <!-- end of ul#nav-categories -->',"\n"


  24. #24
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What the "\t\t\t" and "\n" means?

    you use it through out the code..

    I will appreciate your explanation...

  25. #25
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,194
    Mentioned
    17 Post(s)
    Tagged
    4 Thread(s)
    \t = tab
    \n = new line

    Presentational stuff so that everything doesn't end up on one line. This makes the output easier to read.


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
  •