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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:05:00+00:00 2026-06-07T10:05:00+00:00

I’m making a dropdown menu with information out of my database. It has to

  • 0

I’m making a dropdown menu with information out of my database. It has to get different brands in my dropdown and when selecting a brand and submit search it will show information about that brand. It gets the brands correct from the database but after submit it only shows my last brand. Can somebody help me out… Here is my dropdown menu and search (submit) code:

<div class="bandwielkolom">
    <form action="index.php?lang=nl&p=<?php echo $_GET['p']; ?>#keuze" method="post">
        <table class="bandentabel">
        <tr>
            <th colspan="2">Op merk zoeken<a name="band"></a></th>
        </tr>
        <tr>
            <td>Merk:</td>
            <td>
                <select name="band_merk">
                <option value="0">- Merk -</option>
<?php
    $wielen = $wielclass->getMerkenWielen($website);
    foreach($wielen as $wiel)
    {
        echo "\t\t\t\t\t\t\t\t\t\t\t<option value=\"".$wiel->merk_code."\"";
        if(isset($_GET['search']) && $_GET['search'] == "band" && isset($_GET['wiel']) && $_GET['wiel'] == $wiel->merk_code || isset($_POST['band_submit']) && $_POST['band_merk'] == $wiel->merk_code) { echo " selected=\"selected\""; }
        echo ">".$wiel->merk_naam."</option>\n";
    }
?>
                </select>
            </td>
        </tr>
        <tr>
            <td>&nbsp;</td>
            <td><input type="submit" name="band_submit" value="Zoek"/></td>
        </tr>
        </table>
    </form>
</div>  

This is my class:

Class:

<?php
  class wielen extends connect {
    private $wielenlijst;
    public function getMerkenWielen($database) {
        $sql = "SELECT * FROM ".$database."_wielen ORDER BY merk_nummer";
        try {
            $stmt = $this->db->prepare($sql);
            $stmt->execute();
            $this->wielenlijst = $stmt->fetchAll(PDO::FETCH_OBJ);
            $stmt->closeCursor();
            return $this->wielenlijst;
        }
        catch (Exception $e) {
            die ($e->getMessage());
        }
    }
    public function __construct($dbo) {
        parent::__construct($dbo);
    }
  }
?>

This only show the last brand after submit:

<?php
  if(isset($_POST['band_submit']))
    echo $wiel->merk_naam;
?>

Can somebody help me with this because I cant get it to work

Maybe a fresh look at it will help

thnx for any help

UPDATE:

I got this peace of code now and I will explain what is happening and what I want:

<div class="bandwielkolom">
                        <form action="index.php?lang=nl&p=<?php echo $_GET['p']; ?>#keuze" method="post">
                            <table class="bandentabel">
                                <tr>
                                    <th colspan="2">Op merk zoeken<a name="band"></a></th>
                                </tr>
                                <tr>
                                    <td>Merk:</td>
                                    <td>
                                        <select name="band_merk">
                                            <option value="0">- Merk -</option>
<?php
    $wielen = $wielclass->getMerkenWielen($website);
    $get_wiel = isset($_GET['wiel']) ? $_GET['wiel'] : '';
    $post_wiel = isset($_POST['band_merk']) ? $_POST['band_merk'] : '';
    foreach($wielen as $wiel) {
      if ($_SERVER['REQUEST_METHOD'] === 'POST') {
        $selected = $post_wiel['wiel'] === $wiel->merk_code ? ' selected="selected"' : '' ;
      }
      else {
        $selected = $get_wiel['wiel'] === $wiel->merk_code ? ' selected="selected"' : '' ;
      }
      echo '\t\t\t\t\t\t\t\t\t\t\t<option value="' . $wiel->merk_code . '"' . $selected . '>' . $wiel->merk_naam . '</option>';
    }
?>
                                        </select>
                                    </td>
                                </tr>
                                <tr>
                                    <td>&nbsp;</td>
                                    <td><input type="submit" name="band_submit" value="Zoek"/></td>
                                </tr>
                            </table>
                        </form>
                    </div>
                                                            <?php
if(isset($_POST['band_submit']) && $_POST['band_merk'] == $wiel->merk_code)
    echo $wiel->merk_naam;
?>

Precess code:

if(isset($_POST['band_submit']) && $_POST['band_merk'] == $wiel->merk_code)
    echo $wiel->merk_naam;

I get a selectbox with four options out of my database so that is working correct. These options has data in it like a picture and text. When I select one and press submit he has to show the information of the selected option and that should stay selected.

What is happening now is that when I select a option and press submit nothing happens… The button is working but I dont get any output of the selected option and it wont stay selected.

Doing something wrong but I cant figure out what

Any help is welcome:)

  • 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-07T10:05:02+00:00Added an answer on June 7, 2026 at 10:05 am

    You need to use your for loop again to list them all.

    foreach($wielen as $wiel)
    {
        echo $wiel->merk_naam;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a view passing on information from a database: def serve_article(request, id): served_article
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.