I am trying to create a search function that allows the user to choose multiple categories, select submit, and then the php will return the mysql results that match the selected categories.
I would like to do this without AJAX or jQuery, but I will use those if required. I am newer to the world of PHP, so I think I'm on the right track, but would love some assistance of getting this correct.
HTML
<form action="filter.php" method="post">
<p class="searching">Filter by category</p>
<section class="box"><input type="checkbox" name="fill" class="check" value="Arts/Culture"/><img class="lilIcon" src="img/anc.png"><h5>Arts/Culture</h5></section>
<section class="box"><input type="checkbox" name="fill" class="check" value="Seniors"/><img class="lilIcon" src="img/senior.png"><h5>Seniors</h5></section>
<section class="box"><input type="checkbox" name="fill" class="check" value="Youth"/><img class="lilIcon" src="img/youth.png"><h5>Youth</h5></section>
<section class="box"><input type="checkbox" name="fill" class="check" value="Animals"/><img class="lilIcon" src="img/pet.png"><h5>Animals</h5></section>
<section class="box"><input type="checkbox" name="fill" class="check" value="Community"/><img class="lilIcon" src="img/comm.png"><h5>Community</h5></section>
<section class="box"><input type="checkbox" name="fill" class="check" value="Crisis Support"/><img class="lilIcon" src="img/cs.png"><h5>Crisis Support</h5></section>
<section class="box"><input type="checkbox" name="fill" class="check" value="Environment"/><img class="lilIcon" src="img/leaf.png"><h5>Environment</h5></section>
<section class="box"><input type="checkbox" name="fill" class="check" value="Faith Based"/><img class="lilIcon" src="img/pray.png"><h5>Faith Based</h5></section>
<section class="box"><input type="checkbox" name="fill" class="check" value="People with Disabilities"/><img class="lilIcon" src="img/chair.png"><h5>People with Disabilities</h5></section>
<input type="submit" name="submit" id="filter" value="Filter"/>
</form>
PHP
<?php
$variable=$_POST['fill'];
$i = 0;
foreach ($variable as $variablename) {
$i++;
$variablename[number];
}
$result = "SELECT * FROM opportunity WHERE `Category`=$variablename";
$num_rows = mysql_num_rows($result);
echo "<div class='holder'>";
if(mysql_num_rows($result) > 0)
{
while($results = mysql_fetch_array($result));
}
</div>