0

Hi, Im trying to print out section titles and instructions from a database, however the first section title gets printed twice, I've no idea what I'm doing wrong.

Here's a code snippet:

$query = $this->db->query('SELECT DISTINCT SectionTitle FROM SECTION WHERE SurveyID= '.$number );
            $j=1;
            foreach ($query->result() as $row)
        {
            $secTitle=  $row->SectionTitle;
            echo $secTitle;
            echo "<br>";


            $query2= $this->db->query('SELECT DISTINCT Instructions FROM SECTION WHERE SectionID='. $j.' AND SurveyID= '.$number );
            $j++;
            foreach ($query2->result() as $row2)
            {
            $instr=  $row2->Instructions;
            echo $instr;
            echo "<br>";

            }


        }

And heres my output :

BASIC DEMOGRAPHIC INFORMATION
Your answers to the following questions will be used to customize the cyber security awareness training program to fit a specific user group within your environment.
BASIC DEMOGRAPHIC INFORMATION
Your answers to the following questions will be used to make the training material more fun.
HISTORY AND BACKGROUND - GENERAL
Your answers to the following questions will be used to determine the current level of technology usage within your environment.
HISTORY AND BACKGROUND - TECHNOLOGY
Your answers to the following questions will be used to determine the current level of cyber security awareness and understanding within your environment. Please do not leave out any questions. If you are unsure a the correct answer, choose the answer that you feel might be the right answer.
SPECIFIC SCENARIOS
This information will be used to identify any topics additional to those already identified.
OPEN SECTION



BASIC DEMOGRAPHIC INFORMATION is printed twice, I cant seem to figure out why.

Edited by mike_2000_17: Fixed formatting

1
Contributor
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Zubz15
0

Please ignore this post, I had a minor problem in my database. It's solved now, the code was fine.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.