Title is not entirely clear what is required if more detail is: In mysql db table has, from it to the page of data is displayed in html table this code:
<?php
$db_host = 'localhost';
$db_name = 'DB';
$db_username = 'NAME';
$db_password = 'PASS';
$db_table_to_show = 'TABLE';
$connect_to_db = mysql_connect($db_host, $db_username, $db_password)
or die("Could not connect: " . mysql_error());
mysql_select_db($db_name, $connect_to_db)
or die("Could not select DB: " . mysql_error());
mysql_set_charset("utf8");
$qr_result = mysql_query("select * from " . $db_table_to_show)
or die(mysql_error());
echo '<table id="table">';
echo '<thead>';
echo '<tr>';
echo '<th class="table-fandom">fandom</th>';
echo '<th>author</th>';
echo '<th class="table-name">name</th>';
echo '<th>size</th>';
echo '<th class="table-status">status</th>';
echo '<th>date</th>';
echo '<th>tags</th>';
echo '</tr>';
echo '</thead>';
echo '<tbody>';
while($data = mysql_fetch_array($qr_result)){
echo '<tr>';
echo '<td>' . $data['fandom'] . '</td>';
echo '<td>' . $data['author'] . '</td>';
echo '<td><a href="/goto/' . $data['url'] . '" target="_blank">' . $data['name'] . '</a><div class="menu" style="display: none;"><br> ' . $data['annotation'] . ' </div></td>';
echo '<td>' . $data['size'] . '</td>';
echo '<td>' . $data['status'] . '</td>';
echo '<td>' . $data['date'] . '</td>';
echo '<td>' . $data['tags'] . '</td>';
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
mysql_close($connect_to_db);
?>
Requires that the new records that were added today, has been assigned a special css class within 72 hours. PS Sorry for my english, it's not my native language.
You can do this:
...
while($data = mysql_fetch_array($qr_result)){
if($data['date'] > date('Y-m-d', strtotime('-3 days'))
echo '<tr class="new">';
else
echo '<tr>';
echo '<td>' . $data['fandom'] . '</td>';
echo '<td>' . $data['author'] . '</td>';
echo '<td><a href="/goto/' . $data['url'] . '" target="_blank">' . $data['name'] . '</a><div class="menu" style="display: none;"><br> ' . $data['annotation'] . ' </div></td>';
echo '<td>' . $data['size'] . '</td>';
echo '<td>' . $data['status'] . '</td>';
echo '<td>' . $data['date'] . '</td>';
echo '<td>' . $data['tags'] . '</td>';
echo '</tr>';
}
First you need to add registration time in table. For example you save registration time in unix timestamp. Then you need to use condition after while loop.
while($data = mysql_fetch_array($qr_result))
{
if($data['registration_time'] > strtotime("-3 days") )
{
echo '<tr class="change_color_class">';
}
else
{
echo '<tr class="normal_class">';
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.