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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:45:36+00:00 2026-06-06T22:45:36+00:00

I created a PHP Drop Down which is populated from a MySql Database and

  • 0

I created a PHP Drop Down which is populated from a MySql Database and works just fine, the problem occurs when I want to post the selected in another script. The question is how to post the data to the other script?
This is the source code of the script that implements the drop downs. Please Help!!!!

<?php
$conn = mysql_connect("localhost", "admin", "admin");

if (!$conn) {
    echo "Unable to connect to DB: " . mysql_error();
    exit;
}

if (!mysql_select_db("ekupuvac")) {
    echo "Unable to select EKupuvac: " . mysql_error();
    exit;
}

$query = "SELECT ImeK, KupuvacID FROM kupuvac ORDER BY Saldo DESC";
$result = mysql_query($query) or die(mysql_error());

if (!$result) {
    echo "Could not successfully run query ($query) from DB: " . mysql_error();
    exit;
}

if (mysql_num_rows($result) == 0) {
    echo "No rows found, nothing to print so I am exiting";
    exit;
}

$dropdown = "<select name='ImeK'>";
while($row = mysql_fetch_assoc($result)) {
$dropdown.= "\r\n<option value='{$row['KupuvacID']}'>{$row['ImeK']}</option>";
}
$dropdown .= "\r\n</select>";

echo"Izberi Kupuvac:";
echo $dropdown;

// Second Combo

$conn = mysql_connect("localhost", "admin", "admin");

if (!$conn) {
    echo "Unable to connect to DB: " . mysql_error();
    exit;
}

if (!mysql_select_db("ekupuvac")) {
    echo "Unable to select EKupuvac: " . mysql_error();
    exit;
}

$query2 = "SELECT ImeP, ProzivodID FROM proizvod ORDER BY ImeP";
$result2 = mysql_query($query2) or die(mysql_error());

if (!$result2) {
    echo "Could not successfully run query ($query2) from DB: " . mysql_error();
    exit;
}

if (mysql_num_rows($result2) == 0) {
    echo "No rows found, nothing to print so I am exiting";
    exit;
}

$dropdown2 = "<select name='ImeP'>";
while($row = mysql_fetch_assoc($result2)) {
$dropdown2.= "\r\n<option value='{$row['ProzivodID']}'>{$row['ImeP']}</option>";
}
$dropdown2.= "\r\n</select>";

echo"<br> Izberi Proizvod:";
echo $dropdown2;
echo"<br>";

mysql_free_result($result);
?>
  • 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-06T22:45:38+00:00Added an answer on June 6, 2026 at 10:45 pm

    A <select> box is not enough, you need to enclose it in a form

    ?>
    <form method="post" action="somescript.php">
    <?
    //your controls go here
    ?>
    </form>
    

    then create somescript.php and access your form variables using $_POST

    Also use PDO not mysql_ functions as these arent safe

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

Sidebar

Related Questions

I am new to php, i created drop down which calling data from mysql
I just created a PHP page that spits outs some data from my database
I have created and html form which have a drop down list. This drop
I have a form that contains 5 drop down lists which are created by
I created a script which get from my database the states and price of
I'm trying to create a drop down select option using PHP, MySQL, and ajadx
I am trying to create a drop down list using jQuery, PHP and mySQL,
I have this problem getting my newly created php project on Netbeans work on
I have created a PHP form which requires the user to select a postcode
I created 3 drop down list in my html. For the first drop down,

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.