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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:40:06+00:00 2026-06-16T00:40:06+00:00

In my drop down list, each row has 3 fields from a db. I

  • 0

In my drop down list, each row has 3 fields from a db. I somehow need to pass these to another form where I will reference them in another SQL statement.

I’m not sure how to pass them. Any help would be really appreciated.

<form action='obtainaprice.php' method='POST'>
<?php

echo "<select name='makes' id='searchtext'>\n";

    $query1 = "SELECT DISTINCT make, type, model FROM device ORDER BY make, type, model";

    $result1 = mysql_query($query1)
       or die ("Couldn't execute query.");

    while ($row1 = mysql_fetch_array($result1))
    {
         $i=0;
             echo "<option value= \"" . $i . "\">" . $row1['make'] . " " . $row1['type'] . " " . $row1['model'] . "</option>";

             $i++;
    }

    echo "</select>\n";
?>
<input type="image" id="buttons" alt="Search" img src="images/button.png">
</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-06-16T00:40:06+00:00Added an answer on June 16, 2026 at 12:40 am

    In this case you would make the value of the options the row’s id, which you need to select:

    "SELECT DISTINCT id, make, type, model FROM device ORDER BY make, type, model"
    

    assuming your primary index is called id…

    <option value="<?php echo $row['id']; ?>">
    

    Then on your next page you would run the next query based on the post value for makes…

     "SELECT id, make, type, model FROM device WHERE id = ".$_POST['makes']
    

    of course, you need to sanitize this. You should switch to mysqli or PDO.

    Side note – you should break out of php for writing html. It’s just cleaner. Run your query first so you don’t die in the middle of a select box. I don’t condone use of mysql_ functions but for the sake of example here is what I mean…

    <?php
        $query1 = "SELECT DISTINCT id, make, type, model FROM device ORDER BY make, type, model";
        $result1 = mysql_query($query1)
           or die ("Couldn't execute query.");
    ?>
    <form action='obtainaprice.php' method='POST'>
        <select name='makes' id='searchtext'>
        <?php while ($row1 = mysql_fetch_array($result1)): ?>
            <option value="<?php echo $row['id']; ?>"><?php echo $row1['make']; ?> <?php echo $row1['type']; ?> <?php echo $row1['model']; ?></option>
        <?php endwhile; ?>
        </select>
        <input type="image" id="buttons" alt="Search" img src="images/button.png">
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've a table with multiple rows, each row has a drop down list. I
I have a drop down list that has options that need to be passed
I have a parent page which has a drop down list in it. using
I want to be able to generate a drop down list from items entered
I have one drop down list in my page, which contains two options. What
this is my drop down list: @Html.DropDownListFor(m => m.ReportType, new SelectList(ViewBag.DateRange as List<SelectListItem>, Value,
I have a drop-down list which is generated based on the following sql query:
I have defined a drop down list in html as follows. I have appended
I have about 10 drop down list controls that get populated. Instead of copying/pasting
I have a drop down list where users can select a theme for the

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.