Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6040467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:31:05+00:00 2026-05-23T06:31:05+00:00

Ok, right now I trying to get a list to echo out from mysql

  • 0

Ok, right now I trying to get a list to echo out from mysql using a while loop, but as you can see here http://institute4se.com/plan/ it’s echoing in the wrong order. Why?

The reason for the if statements is to make the top and bottom pieces of the div echo only when the loop reaches the beginning of a new subsection.

If I remove the if statement the list echos out in order but then the beginning and end of the div echo every loop.

You can see my database aka $info here: https://i.stack.imgur.com/QMO2X.png https://i.stack.imgur.com/RsHdb.png

Any thoughts on how to fix it?

 while($info = mysql_fetch_array( $data )) 
 {

if($info['subsection']=='0'){
echo "
<div class='menuSection'>
<div class='sectionHeader' id='header".$info['section']."'><img src='images/status_circ_empty.gif' alt='Section Empty' /><a href='index.php?s=".$info['section']."&ss=".$info['subsection']."'>".$titleArr[$info['section']]."</a><img src='images/arrow_".$currentArrow.".gif' alt='Arrow' class='arrow' /></div>
    <ul class='sectionSubmenu' id='section".$info['section']."' style='display:".$currentSection."'>
"; 
}
else{
echo "<li><img src='images/status_circ_empty.gif' alt='Section Empty' /><a href='index.php?s=".$info['section']."&ss=".$info['subsection']."'>".$info['title']."</a></li>"; 
}
if($info['subsection']=='0'){
echo"
    </ul>
</div>
";
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T06:31:06+00:00Added an answer on May 23, 2026 at 6:31 am

    Here is the fixed code for anyone who is interested:

    while($info = mysql_fetch_array( $data )) 
    { 
    
        // if the current subsection is a new section
        if($info['subsection']==0){
        // if the current section is NOT the first section
        if($info['section']!=0){
        // end the section div
        echo "
                </ul>
        </div>
        ";
        }
    
        // start the section div and add the section header
        echo "
        <div class='menuSection'>
        <div class='sectionHeader' id='header".$info['section']."'><img src='images/status_circ_empty.gif' alt='Section Empty' /><a href='index.php?s=".$info['section']."&ss=".$info['subsection']."'>".$titleArr[$info['section']]."</a><img src='images/arrow_".$currentArrow.".gif' alt='Arrow' class='arrow' /></div>
            <ul class='sectionSubmenu' id='section".$info['section']."' style='display:".$currentSection."'>
            <li><img src='images/status_circ_empty.gif' alt='Section Empty' /><a href='index.php?s=".$info['section']."&ss=".$info['subsection']."'>".$info['title']."</a></li>
    
        ";
    
        }
        // if the current section is not a new section
        else{
            // add the next submenu item
            echo "<li><img src='images/status_circ_empty.gif' alt='Section Empty' /><a href='index.php?s=".$info['section']."&ss=".$info['subsection']."'>".$info['title']."</a></li>"; 
        }
    } 
    echo"
        </ul>
    </div>
    ";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now I'm trying to figure out a way to do things smarter, and
Right now I am trying to call my model, and spit out its results
I'm trying to be better about unit testing my code, but right now I'm
I'm relatively new to Mercurial and my team is trying it out right now
Right now I am only trying to get my getline() function to work. I
I'm trying to implement doubly-linked list in c++ and right now I'm adding iterator
I'm developing an object-oriented PHP website right now and am trying to determine the
I'm trying to design some bookmarklets right now, that connect back to a server
I'm trying to build my own inversion of control container. Right now I store
I'm currently trying to make a small application that performs different duties. Right now

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.