mysqlfetch数组如果没有结果显示消息


mysql fetch array if no results display message

我正在尝试获取一个数据库调用,以显示一条语句,如果没有返回结果,则表示找不到结果。

我该如何对我的代码进行此操作:-

$getFixtures = mysql_query("SELECT ht.name AS hometeam_name, homescore, awayscore, at.name AS awayteam_name, time, date, week, comp.competition AS comp_name, se.name AS season_name
                    FROM fixture
                    JOIN team ht
                    ON ht.id = fixture.hometeam
                    JOIN team at
                    ON at.id = fixture.awayteam
                    JOIN competition comp
                    ON comp.id = fixture.competition
                    JOIN season se
                    ON se.id = fixture.season
                    WHERE se.name = '$season' AND comp.competition = '$competitiontitle' AND date >= '$today' AND at.name = '$teamName' OR ht.name = '$teamName' AND se.name = '$season' AND comp.competition = '$competitiontitle' AND date >= '$today'
                    ORDER BY date ASC
                    ");                     
                    while ($fixtureData = mysql_fetch_array($getFixtures))
                    {
                    $hfixteamlink = strtolower(str_replace(" ","-",$fixtureData['hometeam_name']));
                    $afixteamlink = strtolower(str_replace(" ","-",$fixtureData['awayteam_name']));
                    $date = date("d/m/Y", strtotime($fixtureData['date']));
                    ?> 

提前感谢

Richard

这需要一个IF语句。

$rows = mysql_fetch_array($getFixtures);
if(count($rows))
{
    while ($fixtureData = $rows)
    ...
}
else
{
    echo 'No results found';
}
if ( ! mysql_num_rows($getFixtures)) {
   echo 'No results found.';
} else {
  ...
}