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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:44:40+00:00 2026-06-17T07:44:40+00:00

Below I have a php/mysqli block of code where it creates a drop down

  • 0

Below I have a php/mysqli block of code where it creates a drop down menu:

    $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>';

The HTML for this is:

<select name="modules" id="modulesDrop">
     <option value="">Please Select</option>
</select>

Now I am trying to display a message if the user has selected the option Please Select. But problem is that the message is not being displayed. MY question is how can I get message to be displayed stating that a Module needs to be selected if user selects Please Select?

Below is main code:

    <?php

    ...


        $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 = "";

    ?>

    <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>
    </form>

    <?php


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

    if (isset($_POST['modules']) && $_POST['modules'] == '' ){
    $pHTML = "<span style='color: red'>Please Select a Module</span>";
    }else{


    $assessmentform = "<div id='lt-container'>
    <form action='".htmlentities($_SERVER['PHP_SELF'])."' method='post' id='assessmentForm'>
    <p id='warnings'>{$pHTML}</p>
    <p><strong>View Assessment Details:</p>   
    name='sessionSubmit' /></p>
    </form>
    </div>";

    echo $assessmentform;

    }

    }
?>
  • 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-17T07:44:41+00:00Added an answer on June 17, 2026 at 7:44 am

    You have given value = “” for the option Please Select. So you can directly check the element. Also, you have done it. Please check the line,

    if (isset($_POST['modules']) && $_POST['modules'] == '' ){
        $pHTML = "<span style='color: red'>Please Select a Module</span>";
    }else{
    

    This line will check whether the user selected any value or not.

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

Sidebar

Related Questions

I have php/mysqli and jquery code below where it displays a course drop down
I have a working php/mysqli code below where it inserts questions and answers successfully:
In my code below I have 2 drop down menus. One is a Course
I have a block of code below which inserts data into database using mysqli
I have a mysqli/php code below where it is suppose to insert data into
I have a mysqli/php code below where it is suppose to insert data into
I have the PHP code below. It is supposed to select up to ten
I have a basic mysqli code below where it performs a query to select
I have a basic mysqli code below where it performs a query to select
Possible Duplicate: php/Mysql query with inserting date fails I have a datepicker code below:

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.