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

  • SEARCH
  • Home
  • 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 9144209
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:12:49+00:00 2026-06-17T10:12:49+00:00

I am having trouble displaying the right details after a submit. I think my

  • 0

I am having trouble displaying the right details after a submit. I think my page structure is incorrect What is happening at moment is that if I click on the Module Submit button, nothing is being displayed which is incorrect.

Below is what is suppose to happen: (The page works in 3 parts)

Part 1: Contains a module drop down menu. User selects option from drop down menu and submits. Everytime it is submitted, it changes part 2 and part 3 is hidden. After submission drop down menu goes back to Please Select option.

Part 2: Contains Assessment drop down menu, only appears after user has submitted part 1. When this part is submitted by user selecting option from Assessment drop down menu and clicking on submit button, drop down menu goes back to Please Select and part 3 appears. Part 3 changes everytime part 2 is submitted with different options.

Part 3: Display details from part 2. Only appears and changes depending on Assessment chosen and submitted from part 2. If user submits from part 1, then this part is hidden.

Now my attempt is to seperate the php and phmtl from each other but like I said he problem is that no details is being displayed. Bear with me there is a lot of code but that is because I need to showw how my page is structured. My question is what things do I need to do in order to fix the page structure?

You can see what is happening with the application here: Application

Below is the code which goes in the order it is displayed in: (I tried to limit down as much as I can):

PHP:

         <?php

// connect to the database

$moduleactive = 1;

$sql = "SELECT ModuleId, ModuleNo, ModuleName FROM Module WHERE ModuleActive = ? ORDER BY ModuleNo";


//excute query

$sqlnum = $sqlstmt->num_rows();

$moduleHTML = "";
$moduleHTML .= '<select name="modules" id="modulesDrop">' . PHP_EOL;
$moduleHTML .= '<option value="">Please Select</option>' . PHP_EOL;

while ($sqlstmt->fetch()) {
    $moduleHTML .= sprintf('<option value="%1$s_%2$s_%3$s">%1$s - %2$s</option>' . PHP_EOL, $dbModuleNo, $dbModuleName, $dbModuleId);
}

$moduleHTML .= '</select>';

$pHTML = "";

//Module Submit (Part 1 Submitted)    
if (isset($_POST['moduleSubmit'])) {
    $sessionquery = " 
SELECT s.SessionId, SessionName, SessionDate, SessionTime, ModuleId, SessionActive, Complete 
FROM Session s 
INNER JOIN Session_Complete sc ON sc.SessionId = s.SessionId 
WHERE 
(ModuleId = ? AND SessionActive = ? AND Complete = ?) 
ORDER BY SessionName  
";

    $active   = 1;
    $complete = 1;

    //execute query 

    $sessionnum = $sessionqrystmt->num_rows();

    $sessionHTML = '';

    if ($sessionnum == 0) {
        $pHTML = "<span style='color: red'>Sorry, You have No Assessments under this Module</span>";
    }

    $sessionHTML = '<select name="session" id="sessionsDrop">' . PHP_EOL;
    $sessionHTML .= '<option value="">Please Select</option>' . PHP_EOL;

    while ($sessionqrystmt->fetch()) {
        $sessionHTML .= sprintf("<option value='%s'>%s - %s - %s</option>", $dbSessionId, $dbSessionName, date("d-m-Y", strtotime($dbSessionDate)), date("H:i", strtotime($dbSessionTime))) . PHP_EOL;
    }


    $sessionHTML .= '</select>';

}

//Session Submit (Part 2 Submitted)

if (isset($_POST['sessionSubmit'])) {
    $sessiondetailsquery = " 
    SELECT SessionId, SessionName 
    FROM Session 
    WHERE 
    (SessionId = ?) 
";

    //execute query

    $sessiondetailsqrystmt->bind_result($detailsSessionId, $detailsSessionName);

}

?> 

PHTML:

 <form action="<?php
    echo htmlentities($_SERVER['PHP_SELF']);
    ?>" method="post"> 
    <table> 
    <tr> 
    <th>Module: <?php
    echo $moduleHTML;
    ?></th> 
    </tr> 
    </table> 
    <p><input id="moduleSubmit" type="submit" value="Submit Module" name="moduleSubmit" /></p> 


      <?php
    if ($step == 2) {
        if (!$_POST['moduleSubmit']) {
            if ($_POST['modules'] == '') {
    ?>  
               <span style='color: red'>Please Select a Module</span>  
           <?php
            } elseif (!$sqlnum) {
    ?>  
               <span style='color: red'>Sorry, You have No Assessments under this Module</span>  
            <?php
            } else {
    ?>  
        <p><strong>Assessments:</strong> {$sessionHTML} </p>   
        <p><input id='sessionSubmit' type='submit' value='View Assessment Details' name='sessionSubmit' /></p>  
         <?php
            }
        }
    }
    ?> 

      <?php
    if ($step == 3) {
        if (!$_POST['sessionSubmit']) {
            if ($_POST['session'] == '') {
    ?>  
               <span style='color: red'>Please Select an Assessment</span>  
            <?php
            } else {
    ?>   

    <table> 
    <tr> 
    <td></td> 
    <td><input type='text' id='currentId' name='Idcurrent' readonly='readonly' value='$detailsSessionId' /></td> 
    </tr> 
    <tr> 
    <td><strong>Assessment:</strong></td> 
    <td>{$detailsSessionName}</td> 
    </tr> 
    </table> 
         <?php
            }
        }
    }
    ?> 

    </form> 

        </body> 
    </html>

UPDATE:

Notice: Undefined index: modules in ...on line 66
Notice: Undefined offset: 1 in ... on line 68 
Notice: Undefined offset: 2 in ... on line 69
Notice: Undefined index: modules in ... on line 116

PHP fiddle updated: http://phpfiddle.org/main/code/cbx-6mi

  • 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-06-17T10:12:51+00:00Added an answer on June 17, 2026 at 10:12 am

    I am not entirely sure about how you want the structure to be, but from what i could understand this is the answer to your question.

    You should see the structure, and hopefully you can use it =)

    The idea is to show a section depending on how much info the user have given us.

    And also allow the user to go back and change old data.

    I have commented out some of your “code”, and added some options that you should remove. But this things should show you the structure suggested without you being forced to input your code.

    <html>
    <body>
    <form action="" method="post"> 
        <table> 
            <tr> 
                <th>
                    <?php
                        // connect to the database
                        //$sql = "SELECT ModuleId, ModuleNo, ModuleName FROM Module WHERE ModuleActive = ? ORDER BY ModuleNo";
                        //excute query
                        //$sqlnum = $sqlstmt->num_rows();
                    ?>
                    Module: 
                    <select name="module" id="modulesDrop">
                        <option value="">Please Select</option>
                        <?php
                            /*
                            while ($sqlstmt->fetch()) {
                                echo sprintf('<option value="%1$s_%2$s_%3$s">%1$s - %2$s</option>' . PHP_EOL, $dbModuleNo, $dbModuleName, $dbModuleId);
                            }
                            */
                        ?>
                        <option value="test">test</option>
                    </select>
                </th> 
            </tr> 
        </table> 
        <input id="moduleSubmit" type="submit" value="Submit Module" name="moduleSubmit" />
    </form>
    <?php
    if(isset($_POST["module"]))
    {
    ?>
    <form action="" method="post"> 
        <input type="hidden" name="module" value="$_POST[module]">
        Assigments: 
        <?php
            $sessionquery = "SELECT s.SessionId, SessionName, SessionDate, SessionTime, ModuleId, SessionActive, Complete 
            FROM Session s 
            INNER JOIN Session_Complete sc ON sc.SessionId = s.SessionId 
            WHERE 
            (ModuleId = ? AND SessionActive = ? AND Complete = ?) 
            ORDER BY SessionName";
    
            //execute query 
    
            //$sessionnum = $sessionqrystmt->num_rows();
    
            if ($sessionnum == 0 && false) // "&& false" should ofcourse be removed
            {
            ?>
        <span style='color: red'>Sorry, You have No Assessments under this Module</span>
            <?php
            }
            else
            {
            ?>
        <select name="session" id="sessionsDrop">
            <option value="">Please Select</option>
            <?php
                /*
                while ($sessionqrystmt->fetch()) {
                    $sessionHTML .= sprintf("<option value='%s'>%s - %s - %s</option>", $dbSessionId, $dbSessionName, date("d-m-Y", strtotime($dbSessionDate)), date("H:i", strtotime($dbSessionTime))) . PHP_EOL;
                }
                */
                echo "<option value='tst'>tst</option>";
            ?>
        </select>
        <br>
        <input type="submit" value="Submit Assigments">
    </form>
    <br>
    <br>
        <?php
        if(isset($_POST["session"]))
        {
            ?>
                <table> 
                    <tr> 
                        <td></td> 
                        <td><input type='text' id='currentId' name='Idcurrent' readonly='readonly' value='$detailsSessionId' /></td> 
                    </tr> 
                    <tr> 
                        <td><strong>Assessment:</strong></td> 
                        <td>{$detailsSessionName}</td> 
                    </tr> 
                </table> 
            <?php
            }
        }
    }
    ?>
    </body>
    </html>
    

    If you only want one “step” to be shown at the time, use “else if” instead of “if” (of course it need a little more than that, but you should understand how to do it from that?)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble with displaying image from db. I think that method for saving
I am having trouble displaying a raw YUV file that it is in NV12
I am having trouble displaying the number of opencases that are found in my
I am having trouble displaying some jason from a page. The data is there
I have a simple login page but i am having trouble displaying the logged
I'm having trouble displaying a dialog during the uninstall sequence that runs from the
I am having trouble displaying an image from the internet on my html page.
I am having trouble displaying results recieved from asp.net WebMethod. I have a HTML
I am having trouble displaying Date s in the format I want in my
I am having trouble displaying an background image in my ASP.NET MVC 2 application.

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.