php - Selecting records older than 15 days ago -
how can display records older 15 days ago column updatetime
?
code
$conn = mysql_connect($servername,$database_username,$database_password); $sql = 'select * user_shift_test2'; $result = mysql_query( $sql, $conn ); if(! $result ) { die('could not data: ' . mysql_error()); } $i=1;
while loop fetching rows
while($row = mysql_fetch_array($result, mysql_assoc)) { echo '<tr>'; $res = $row['userid']; echo "<td><input type='checkbox' name='chk[]' value='$res'></td>"; echo "<td>{$row['userid']} <br> </td>". "<td>{$row['id']} <br> </td>". "<td>{$row['name']} <br> </td>". "<td>{$row['shifttime']} <br> </td>". "<td>{$row['dayoff']} <br> </td>". "<td>{$row['updatetime']} <br> </td></tr>"; } ?>
you can in pure sql , filter records on db side. try using date_sub()
:
select * user_shift_test2 t t.updatetime < date_sub(now(), interval 15 day)
Comments
Post a Comment