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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:10:08+00:00 2026-05-27T15:10:08+00:00

I am trying to connect to MySQL and populate the data to Dropdown. Here

  • 0

I am trying to connect to MySQL and populate the data to Dropdown. Here is my code. Some reason dropdown is not getting populated. Please suggest.

Here is the code.

<html>
<body>

<?php
$mysqli_connection = new mysqli($db_host, $db_username, $db_password, $db_database);
if (isset($_POST['Submit_1'])) {
    require 'submit.php';
    require 'validate.php';
    if ($form_errors = validate_form()) {
        show_form($form_errors);
    }
    else
    {
        form_submit_1();
    }
}
else
{
    show_form();
}
function show_form($errors = '')
{
    // were there any errors?  
    if ($errors) {
        //show errors
    }

    ?>
<form name="myForm" id="myForm" method="post">
    <?php
    $sql = "SELECT id, code FROM table1";
    $result11 = $mysqli_connection->query($sql);
    echo " <select name = \"state1\" id=\"state1\">";
    while ($row = $result11->fetch_assoc()) {
        echo "<option value = $row[id]>$row[code]</option>";
    }
    echo "</select>";
    ?>
</form>
    </body>
</html>
<?php
} // End of show_form()
?>
  • 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-05-27T15:10:09+00:00Added an answer on May 27, 2026 at 3:10 pm

    This part:

    echo "<option value = $row[id]>$row[code]</option>";
    

    Is not valid, it should be something like this:

    echo "<option value=\"{$row['id']}\">{$row['code']}</option>";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to pull some html data from a mysql database to populate a
I am trying connect to MySQL database from ASP.net code. some my connection is
Hi am using MS visual VC++ 2008 trying to connect mysql though vc++ code..getting
I am trying to connect to mysql and am getting an error. I put
I am trying to connect to MySQL via PHP through the following code <?php
I am trying to connect to mysql database from jsp page. The connection code
I am trying to connect MySQL to Windows following the instructions given here .
I'm trying to connect MySQL database and getting out datas I need it to
I'm trying to connect to mysql from rust code. I've tried these steps. 1.
im getting this error while trying to connect a mysql database to an editor,

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.