Jump to content

Dropdown Search


RobertFullmen

Recommended Posts

Hey All.

 

I'm trying to modify a search I have setup. What I want to do is take out the text field and replace it with a dropdown menu. It starts with an html form

Old working code:

<form action="result.php" method="post">
          <div align="center">Search:
            <input type="text" name="search" />
  <input type="submit" />
          </div>
        </form>

 

New non working code:

<form action="result.php" method="POST">
<select name="dropdown">
<option value="option1">option1</option>
<option value="option2">option2</option>
<option value="option3">option3</option>
</select><input type="submit" name="search" />
</form>

 

That should open up result.php which searches two fields in a mysql database and prints of the results.

 

result.php

$var = $_POST["search"];


  $data = mysql_query("select * FROM database1 WHERE field1 LIKE '$var' ||  field2 LIKE '$var'")
or die(mysql_error()); 

echo $data;

?>

 

If result.php not receiving the info in the dropdown or am I handling it wrong in the php?

 

Thanks so much.

Link to comment
https://forums.phpfreaks.com/topic/238065-dropdown-search/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.