I have a code that has a drop down of months and when selected, the data of that specific month shows. For example:
<div style="width:700px;margin-left:auto;margin-right:auto;text-align:center;">
<h2>List of sessions</h2>
<select name = "Select">
<option value="jan" onclick="showDiv('j')">January</option>
<option value="feb" onclick="showDiv('f')">February</option>
<option value="mar" onclick="showDiv('m')">March</option>
<option value="apr" onclick="showDiv('a')">April</option>
<option value="may" onclick="showDiv('m')">May</option>
</select>
</div>
<div class="content" id="f">
<?php $sql = DB::getInstance()->get('sessions', array('MONTH(date)','=' ,'2'));
//mysql_db_query('nio', "SELECT DATE");
echo "<table class='table table-hover'style='color: orange' > "
. "<thead>
<tr>
<th>Title</th>
<th>Date</th>
<th>Start Time</th>
<th>End Time</th>
</tr>
</thead>
<tbody>";
if(!$sql->count()){
echo 'No data';
}else {
foreach ($sql->results() as $sql){
echo "<tr style='background-color: black'>";
echo "<td>" . $sql->title . "</td>";
echo "<td>" . $sql->date . "</td>";
echo "<td>" . $sql->start_time . "</td>";
echo "<td>" . $sql->end_time . "</td>";
echo "</tr>";
?>
<?php }}echo" </tbody>";
echo" </table>";?>
</div>
The div class above is for showing the data for only February. I have to have for every month which means if I follow this way, I'll repeat the above div about 11 times. Is there a better approach to doing this?