我这里有个小问题。我需要在我的页面中做一个条件,如果在数据库中没有找到数据,应该输出一条消息
这是代码
foreach ($movies as $movie)
{
$movie_id = $movie['movie_id'];
$movie_name = $movie['movie_name'];
$movie_category = $movie['movie_category'];
$movie_display = $movie['movie_display'];
if ($movie_id){
echo '<tr>';
echo '<td>' . $movie_name . '</td>';
echo '<td>' . $movie_category . '</td>';
echo '<td align="center">';
if ($movie_display==1) { echo "YES";} else { echo "NO";}
echo '</td>';
echo '<td align="center">';
echo "<a href='editmovies.php?movie_id={$movie_id}'>". edit .'</a><br/></td>';
echo '<td align="center">';
echo "<a class='delete' href='deletemovie.php?movie_id={$movie_id}'>". delete .'</a><br/></td>';
echo '</tr>';
}
else {
echo 'no results were found';
}
}
echo '</table>';
即使数据库为空,也没有消息传递,我不知道为什么。
谢谢