HELP! Need php code to search from drop downlist

Discussion in 'PHP' started by saturn100, Jun 4, 2011.

  1. #1
    OK I though this would be easy enough but it aint

    I have set up a simple drop down form with a few options
    What I want to do is when someone selects an option and presses search (or go or what ever)
    results appear brought from my data bases and are displayed as a simple table

    Is there any script that will do this I thought this would be easy enough but I have been looking and cant find anything
     
    saturn100, Jun 4, 2011 IP
  2. IAreOwn

    IAreOwn Active Member

    Messages:
    46
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    95
    #2
    you will have to code it yourself.
     
    IAreOwn, Jun 4, 2011 IP
  3. MarPlo

    MarPlo Member

    Messages:
    97
    Likes Received:
    2
    Best Answers:
    2
    Trophy Points:
    48
    #3
    Hy,
    Try adapt this code:
    
    <?php
    $tabel_html = '';
    
    // here connect to mysql
    $val = 'value_to_search';              // here you must store the value from your form
    
    $cerereSQL = "SELECT * FROM `nume_tabel` WHERE `coloana`='$val'";
    $rezultat = mysql_query($cerereSQL);
    
    if(mysql_num_rows($rezultat) > 0) {
      $tabel_html = '<table border="1">';
    
      while($rand = mysql_fetch_array($rezultat)) {
        $tabel_html .= '<tr><td>' .$rand['col1']. '</td><td>' .$rand['col2']. '</td></tr>';
      }
    
      $tabel_html .= '</table>';
    }
    
    echo $tabel_html;
    ?> 
    
    PHP:
     
    MarPlo, Jun 4, 2011 IP