I have this function which gets list from database and displays it in the table on the page. However, I need to input if statement in front of $row[“title”] which checks if $row[“mydate”] is within one month of today’s date, then display “New”, otherwise don’t display anything.
Basically, any lectures which are within 30 days from today should show New in front of the title.
How do I achieve this? I tried inputting if statement there, but it display that whole if statement as a text there.
function uk()
{
$output = '';
$result = db_query("SELECT * FROM lecture where groups='uk'");
if(mysqli_num_rows($result) > 0)
{
$output .= '<div id="style2" style="overflow-x:auto;">
<table>
<tr>
<th class="text-center">Date</th>
<th class="text-center">Title</th>
<th class="text-center">Venue</th>
<th class="text-center">Duration</th>
<th class="text-center">Size (MB)</th>
<th class="text-center">Link</th>
</tr>';
while($row = mysqli_fetch_array($result))
{
$output .= '
<tr>
<td>'.$row["mydate"].'</td>
<td>'.$row["title"].'</td>
<td>'.$row["venue"].'</td>
<td>'.$row["duration"].'</td>
<td>'.$row["size"].'</td>
<td><a href="../'.$row["path"].$row["file_name"].'">Save</a></td>
</tr>
';
}
echo $output;
}
else
{
echo 'Data Not Found';
}
}