www.webdeveloper.com
Results 1 to 6 of 6

Thread: No output after submit

  1. #1
    Join Date
    Jun 2012
    Posts
    23

    No output after submit

    Hallo,
    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 bij database but after submit nothing happens. Can somebody help me out... Here is my dropdown menu and search (submit) code:

    PHP 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 Code:
    <?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);
        }
        
    }

    ?>
    Maybe a fresh look at it will help

    thnx for any help

  2. #2
    Join Date
    Jan 2009
    Posts
    3,346
    Are you posting to the same file (index.php)? I'm not seeing anything right off that stands out to me.

  3. #3
    Join Date
    Jun 2012
    Posts
    23
    No I'm not that is just the URL after submit so nothig special..

    I still cant get it to work... somebody that can help me out here?

    Tnx in advance

  4. #4
    Join Date
    Jun 2012
    Posts
    23
    I got this peace of code now and I will explain what is happening and what I want:

    PHP 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);
        
    $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:

    PHP 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

  5. #5
    Join Date
    May 2004
    Location
    chennai, tamil nadu, India
    Posts
    448
    Actually $post_wiel['wiel'] is same as $_POST['band_merk']['wiel'] is this correct ?

    Is $_POST['band_merk']['wiel'] valid ?

  6. #6
    Join Date
    Jun 2012
    Posts
    23
    Hi thanks for the reply but I dont really get what you mean... can you be more specific

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles