I have this code:
<?php
$platform_id = 7;
$query="SELECT * FROM game WHERE game_id IN (SELECT game_id FROM game_platform WHERE platform_id=".$platform_id.") AND game_release BETWEEN '2015-08-01' AND '2015-08-31' ORDER BY game_release";
$result=mysqli_query($link,$query) or die (mysqli_error());
echo"<table border=1>
<tr>
<th width=40px>Day</th>
<th width=270px>Title</th>
<th width=203px>Genre</th>
<th width=203px>Developer</th>
<th width=205px>Publisher</th>
<th width=61px>Retail?</th>
<th width=30px height=30px></th>
<th width=104px>Note</th>
</tr>";
while($row=mysqli_fetch_assoc($result))
{
echo"
<tr>
<td> ". (new DateTime($row['game_release']))->format("j") ." </td>
<td>{$row['game_name']}</td>
<td>";
$query="SELECT * FROM genre WHERE genre_id=".$row['game_genre'];
$genreresult=mysqli_query($link,$query); $genrerow=mysqli_fetch_assoc($genreresult);
echo $genrerow['genre_name'];
echo "</td>
<td>{$row['game_dev']}</td>
<td>{$row['game_pub']}</td>
<td>{$row['game_type']}</td>
<td><a href=\"{$row['game_site']}\" target=\"_blank\"><img src=\"images/officialwebsite.png\" title=\"Official website\"/></a>
<a href=\"{$row['game_trailer']}\" target=\"_blank\"><img src=\"images/youtube.png\" title=\"Trailer\"/></a></td>
<td>{$row['game_note']}</td>
</tr>";
}
echo"</table>";
?>
I want to show a message when there are no releases in said month, because right now I get an empty table which is not really user-friendly nor visually attractive.
I found this code on this site, but I get a syntax error due to .isEmpty.
<?php
$platform_id = 7;
$query="SELECT * FROM game WHERE game_id IN (SELECT game_id FROM game_platform WHERE platform_id=".$platform_id.") AND game_release BETWEEN '2015-08-01' AND '2015-08-31' ORDER BY game_release";
$result=mysqli_query($link,$query) or die (mysqli_error());
echo"<table border=1>
<tr>
<th width=40px>Day</th>
<th width=270px>Title</th>
<th width=203px>Genre</th>
<th width=203px>Developer</th>
<th width=205px>Publisher</th>
<th width=61px>Retail?</th>
<th width=30px height=30px></th>
<th width=104px>Note</th>
</tr>";
if($result.isEmpty())
echo "Unfortunately there are no releases this month!";
else
{
while($row=mysqli_fetch_assoc($result))
{
echo"
<tr>
<td> ". (new DateTime($row['game_release']))->format("j") ." </td>
<td>{$row['game_name']}</td>
<td>";
$query="SELECT * FROM genre WHERE genre_id=".$row['game_genre'];
$genreresult=mysqli_query($link,$query); $genrerow=mysqli_fetch_assoc($genreresult);
echo $genrerow['genre_name'];
echo "</td>
<td>{$row['game_dev']}</td>
<td>{$row['game_pub']}</td>
<td>{$row['game_type']}</td>
<td><a href=\"{$row['game_site']}\" target=\"_blank\"><img src=\"images/officialwebsite.png\" title=\"Official website\"/></a>
<a href=\"{$row['game_trailer']}\" target=\"_blank\"><img src=\"images/youtube.png\" title=\"Trailer\"/></a></td>
<td>{$row['game_note']}</td>
</tr>";
}
}
echo"</table>";
?>
I kept reading and there doesn't seem to be another way, because while-loops don't have 'else's?
How can I solve this? Thanks!