I have scoured for similar posts and information regarding my issue but can't find any that have been of great help. I have a form on a webpage that consists of 5 dropdown menus, each with different options, the user will select an option from each drop down menu and then hit the submit button. At this point, I want to run a query on the database to look for matching criteria to all the options that are "selected". Right now I don't need to match all the fields, because I'm just testing, so I just want to check say one field. The form I am using is like this:
<div class="section-two">
<div class="row bound-box">
<div class="col-lg-8 col-md-8 col-sm-8 col-lg-offset-2 col-md-offset-2 col-sm-offset-2 main clearfix">
<form id="nl-form" class="nl-form" action="searchpubs.php" method="post">
I feel to visit
<select id="category">
<option value="anywhere" selected>anywhere</option>
<option value="pub">a pub</option>
<option value="nightclub">a nightclub</option>
<option value="brewery">a brewery</option>
<option value="stripclub">a gentleman's club</option>
</select>
<br/>that
<select id="foodDrink">
<option value="food" selected>serves food</option>
<option value="drinks">serves drinks only</option>
</select>
and has
<br/>
<select id="extra">
<option value="poolTable" selected>a pool table</option>
<option value="danceFloor">a dance floor</option>
<option value="tv">tv's</option>
<option value="everything">everything</option>
<option value="anything">anything</option>
</select>
. It's within<br>
<select id="distance">
<option value="anyDistance" selected>any distance</option>
<option value="5">5 km</option>
<option value="10">10 km</option>
<option value="15">15 km</option>
<option value="20">20 km</option>
</select>
from me<br> and is open
<select id="hours">
<option value="late" selected>past 12 a.m.</option>
<option value="allDay">all day</option>
<option value="weekdays">on weekdays</option>
<option value="sundays">on sundays</option>
<option value="anytime">anytime</option>
</select>
<div class="nl-submit-wrap">
<button class="nl-submit" type="submit">Find Your Pub</button>
</div>
<div class="nl-overlay"></div>
</form>
</div><!--column-->
</div><!-- row -->
</div><!--section-two-->
So for instance, if the user has selected the option "serves food" under the select id "foodDrink", I want to run a query on our database to search the column labelled "food" for any row that contains "yes" in that column. Then display all of the matching criteria in the browser. Right now it doesn't need to be formatted etc, I just want to see it in the browser to ensure the query works. Can anybody help me with this, and possibly understand how to add additional queries when ready.
I'm currently connecting to my DB like this:
<?php
//DATABASE CONNECTION INFO BELOW:
$hostname="hostname";
$database="dbname";
$username="myusername";
$password="mypassword";
$link = mysql_connect($hostname, $username, $password);
if (!$link) {
die('Connection failed: ' . mysql_error());
}
$db_selected = mysql_select_db($database, $link);
if (!$db_selected) {
die ('Can\'t select database: ' . mysql_error());
}
mysql_close($link);
?>