I have a table in the database(myTable) listed as such
**Color** **State** **Fruit**
Red Idaho Plum
Blue Kentucky Orange
Yellow Florida Cherry
Green Hawaii Apple
Red Michigan grape
Blue Alabama Bannana
Red Nevada Apple
I have JQuery Buttons on HTML page where if you click a button it toggles a table that displays the above information
<button type="button" class="btn btn-primary" id="button" value="Toggle table">Red Colors</button>
<button type="button" class="btn btn-primary">Blue Colors</button>
<button type="button" class="btn btn-primary">Yellow Colors</button>
<button type="button" class="btn btn-primary">Orange Colors</button>
<button type="button" class="btn btn-primary">Green Colors</button>
<div class="container">
<table class="table" id="table">
<thead>
<tr>
<th>Color</th>
<th>State</th>
<th>Fruit</th>
</tr>
</thead>
<tbody>
<tr>
<td>Red</td>
<td>Idaho</td>
<td>Plum</td>
</tr>
<tr>
<td>Blue</td>
<td>Kentucky</td>
<td>Orange</td>
</tr>
<tr>
<td>Yellow</td>
<td>Florida</td>
<td>Cherry</td>
</tr>
<tr>
<td>Green</td>
<td>Hawaii</td>
<td>Apple</td>
</tr>
<tr>
<td>Red</td>
<td>Michigan</td>
<td>grape</td>
</tr>
<tr>
<td>Blue</td>
<td>Alabama</td>
<td>Bannana</td>
</tr>
<tr>
<td>Red</td>
<td>Nevada</td>
<td>Apple</td>
</tr>
</tbody>
</table>
</div>
CSS
#table{
display: none;
}
Script
$(document).ready(function()
{
$("#button").click(function()
{
$("#table").toggle();
});
});
What i want to happen is i click on the red colors button and a table will show up displaying only the entries with red in its first column. Click on the Blue button that table only displays items with Blue in the Color Column.
I know the sql will go something like this
SELECT * FROM myTable WHERE color =""