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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:34:51+00:00 2026-06-13T01:34:51+00:00

I want to store variables into a while loop for my mysqli:fetch() statement, problem

  • 0

I want to store variables into a while loop for my mysqli:fetch() statement, problem is that I think I am writing the code incorrectly. Especially for the variable $dataArraySession, can anybody look at code below and state what is the correct way in writing the code below:

          $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[$dbModuleId]['Sessions'][$dbSessionId]['SessionDate'] = $dbSessoonDate['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>';
        }


 if ($sessionnum > 0) {

 ?>

     <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-13T01:34:52+00:00Added an answer on June 13, 2026 at 1:34 am

    There are several errors in your code:

    1. After

      $dataArraySession = array();
      

      , $dataArraySession is an array, that’s all. So assigning

      $dataArraySession[$dbModuleId]=something;
      

      is valid, but accessing/assigning

      $dataArraySession[$dbModuleId]["Sesssions"]
      

      (in your while-loop) is invalid, because $dataArraySession[$dbModuleId] is still undefined;

    2. $dbSessionDate is a bound value from $sessionqrystmt->bind_result(), so it would probably be a string or a number, so

      ... = $dbSessionDate['SessionTime'] = ...
      

      is invalid, because it’s just a string, not an array;

    3. In your output loop, you’re also echoing invalid variables.

      In your while-loop, $dataArraySession is defined as

      array(
        [module_id]s => array(
          'Sessions' => array (
            [session_id]s => array (
              'SessionDate' => _value_
            )
          )
        )
      )
      

      So with

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

      ,$sessionData is only at the level of 'Sessions' => array (..., thus $sessionData has only one key, 'Sessions', and both $sessionData['sessionDate'] and $sessionData['sessionTime'] are invalid.

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

Sidebar

Related Questions

hi i want to store textfield data in a variable but my code is
I want to store the password used for signing in a financial application that
I have several variables in an SSIS package that I would like inserting into
I want to store 2 variables in a value, but I not sure with
I want to store the output of text file into a variable, so I
I read somewhere that you should separate you web pages into 3 tiers: Fetch,
I'm using Netbeans and I want to store ResultSet results into an Integer variable,
I have problem with return statment >.< I want to store all magazine names
I want to store a $ character in a PHP variable. $var = pas$wd;
I am a new developer on Android and I want store user data in

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.