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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.