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 8739677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:58:57+00:00 2026-06-13T10:58:57+00:00

I am using the if $_REQUEST statement you mentioned but what I want to

  • 0

I am using the if $_REQUEST statement you mentioned but what I want to do is that if the if statement is met, display the $echo, else display the contents below (session drop down menu and form)

The problem is though is that even though it displays an echo, it displays an undefined notice stating sessionnum is undefined in line 179.

My question is that for the else statement where am I suppose to put the closing bracket in the code below:

if (isset($_POST['modulesubmit'])) {

     if($_REQUEST['modulesDrop']==''){

         echo "Please Select a Module from the Drop Down Menu Above";

     }
     else{  

 var_dump($_POST['modulesDrop']);

        $sessionquery = "
             SELECT SessionId, SessionDate, SessionTime, ModuleId
             FROM Session
             WHERE
             (ModuleId = ?)
             ORDER BY SessionDate, SessionTime 
            ";

$sessionqrystmt=$mysqli->prepare($sessionquery);
// You only need to call bind_param once
$sessionqrystmt->bind_param("s",$_POST['modulesDrop']);
// get result and assign variables (prefix with db)

$sessionqrystmt->execute(); 

$sessionqrystmt->bind_result($dbSessionId,$dbSessionDate,$dbSessionTime, $dbModuleId);

 $sessionqrystmt->store_result();

$sessionnum = $sessionqrystmt->num_rows();   

    $dataArraySession = array();

 while ( $sessionqrystmt->fetch() ) { 

 $dataArraySession[$dbSessionId]['SessionDate'] = $dbSessionDate; 
 $dataArraySession[$dbSessionId]['SessionTime'] = $dbSessionTime;

}

foreach ($dataArraySession as $sessionId => $sessionData) {



   $sessionHTML = ""; 
   $sessionHTML .= '<select name="session" id="sessionsDrop">'.PHP_EOL;
   $sessionHTML .= '<option value="">Please Select</option>'.PHP_EOL;           
   $sessionHTML .= "<option value='$sessionId'>" . $sessionId . " - " . $sessionData['SessionDate']. " - " . $sessionData['SessionTime'] ."</option>".PHP_EOL;        
   $sessionHTML .= '</select>';

        }
} //closing bracket for else statment
 if ($sessionnum > 0) { //error line is here

 ?>

     <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
     <p>Sessions: <?php echo $sessionHTML; ?><input id="sessionSubmit" type="submit" value="Submit" name="sesionsubmit" /></p>      
    </form>       

<?php

}
else {
 echo "<p>Sorry, You have No Sessions under this Module</p>";
}

?>
  • 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-13T10:58:58+00:00Added an answer on June 13, 2026 at 10:58 am

    what you want is to declare any variables that you plan on using inside your IF conditions that will change/reset its value at the top of your page.

    Otherwise you will get undefined index warnings. You can try to do @ to silence the warning as well.

    $sessionnum = 0;
    
    if (isset($_POST['modulesubmit'])) {
    
         if($_REQUEST['modulesDrop']==''){
    
             echo "Please Select a Module from the Drop Down Menu Above";
    
         }
         else{  
    
     var_dump($_POST['modulesDrop']);
    
            $sessionquery = "
                 SELECT SessionId, SessionDate, SessionTime, ModuleId
                 FROM Session
                 WHERE
                 (ModuleId = ?)
                 ORDER BY SessionDate, SessionTime 
                ";
    
    $sessionqrystmt=$mysqli->prepare($sessionquery);
    // You only need to call bind_param once
    $sessionqrystmt->bind_param("s",$_POST['modulesDrop']);
    // get result and assign variables (prefix with db)
    
    $sessionqrystmt->execute(); 
    
    $sessionqrystmt->bind_result($dbSessionId,$dbSessionDate,$dbSessionTime, $dbModuleId);
    
     $sessionqrystmt->store_result();
    
    $sessionnum = $sessionqrystmt->num_rows();   
    
        $dataArraySession = array();
    
     while ( $sessionqrystmt->fetch() ) { 
    
     $dataArraySession[$dbSessionId]['SessionDate'] = $dbSessionDate; 
     $dataArraySession[$dbSessionId]['SessionTime'] = $dbSessionTime;
    
    }
    
    foreach ($dataArraySession as $sessionId => $sessionData) {
    
    
    
       $sessionHTML = ""; 
       $sessionHTML .= '<select name="session" id="sessionsDrop">'.PHP_EOL;
       $sessionHTML .= '<option value="">Please Select</option>'.PHP_EOL;           
       $sessionHTML .= "<option value='$sessionId'>" . $sessionId . " - " . $sessionData['SessionDate']. " - " . $sessionData['SessionTime'] ."</option>".PHP_EOL;        
       $sessionHTML .= '</select>';
    
            }
    } //closing bracket for else statment
     if ($sessionnum > 0) { //error line is here
    
     ?>
    
         <form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
         <p>Sessions: <?php echo $sessionHTML; ?><input id="sessionSubmit" type="submit" value="Submit" name="sesionsubmit" /></p>      
        </form>       
    
    <?php
    
    }
    else {
     echo "<p>Sorry, You have No Sessions under this Module</p>";
    }
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im using niceForms to make my drop downs and below is what I have
Hopefully the answer is no, but are there any problems with using Request.Params instead
I want tot send a friend request using the Facebook Android SDK. I'm currently
I am making a simple ajax request using jquery . Below is my ajax
In My app I am using Soap request, In that Soap request I need
I'm new to using CURL, but I have successfully got it to submit ordinary
I am using ADO.Net Data Services and have a Service Operation that ends up
I have executed the following create statement using SQLWorkbench at my target postgresql database:
How do I handle NullReferenceException for the below statement as I get null exception
I'm trying to request a single location update using the new LocationManager.requestSingleUpdate() method, but

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.