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

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -