Show MYSQL Entries By Specific Day

List MYSQL Database Entries By Specific Day

With the following form we are trying to filter the results from an exact day. Since the date in the database uses the typical date format 2012-01-13, we can grab the date, month and day post variable and get results for that day.

This example uses a table to output data.

<?php
if (count($_POST) > 0) {
$my_date=$_POST['date'].'-'.$_POST['month'].'-'.$_POST['day'];
} ?>

<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<select name="date">
<option value="2012">2012</option>
<option value="2011">2011</option>
<option value="2010">2010</option>
</select>

<select name="month">
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>

<select name="day">
<option value="01">1</option>
<option value="02">2</option>
<option value="03">3</option>
<option value="04">4</option>
<option value="05">5</option>
<option value="06">6</option>
<option value="07">7</option>
<option value="08">8</option>
<option value="09">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<input type="submit" name="submit" value="submit" /></form>
<div>

<?php
echo '<table align="center" cellspacing="0" cellpadding="5">
<tr>
<td align="left"><b># Entries</b></td>
<td align="left"><b>Name</b></td>
<td align="left"><b>Username</b></td>
<td align="left"><b>Email</b></td>
<td align="left"><b>Phone Number</b></td>
<td align="left"><b>Date</b></td>

</tr>';
$command= "SELECT member_id, name, username, email_address, phone_number, date FROM tablename WHERE date='$my_date' ORDER BY date desc";
$result = mysqli_query($db, $command);
if ($result && mysqli_num_rows($result) > 0) {
$number = 0;
while ($row = mysqli_fetch_assoc($result)) {
$number = $number + 1;

$bg =($bg=='#DCEDE5' ? '#f9f9f9' : '#DCEDE5');
echo '<tr bgcolor="' . $bg . '">
<td align="left">' .$number. '</td>
<td align="left">' .$row["name"]. '</td>
<td align="left">' .$row["username"]. '</td>
<td align="left">' .$row["email_address"]. '</td>
<td align="left">' .$row["phone_number"]. '</td>
<td align="left">' .$row["date"]. '</td>
</tr>';
}
echo '</table>';
}
?></div>